## Sid Meier's Civilization 4
## Copyright Firaxis Games 2006
## 
## CvEventManager
## This class is passed an argsList from CvAppInterface.onEvent
## The argsList can contain anything from mouse location to key info
## The EVENTLIST that are being notified can be found 


from CvPythonExtensions import *
import CvUtil
import CvScreensInterface
import CvDebugTools
import CvWBPopups
import PyHelpers
import Popup as PyPopup
import CvCameraControls
import CvTopCivs
import sys
import CvWorldBuilderScreen
import CvAdvisorUtils
import CvTechChooser

import CvIntroMovieScreen
import CustomFunctions
import Animosity

# globals
cf = CustomFunctions.CustomFunctions()
gc = CyGlobalContext()
localText = CyTranslator()
PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo
objAnimosity = Animosity.Animosity()

# globals
###################################################
class CvEventManager:
	def __init__(self):
		#################### ON EVENT MAP ######################
		#print "EVENTMANAGER INIT"
				
		self.bCtrl = False
		self.bShift = False
		self.bAlt = False
		self.bAllowCheats = False
		
		# OnEvent Enums
		self.EventLButtonDown=1
		self.EventLcButtonDblClick=2
		self.EventRButtonDown=3
		self.EventBack=4
		self.EventForward=5
		self.EventKeyDown=6
		self.EventKeyUp=7
	
		self.__LOG_MOVEMENT = 0
		self.__LOG_BUILDING = 0
		self.__LOG_COMBAT = 0
		self.__LOG_CONTACT = 0
		self.__LOG_IMPROVEMENT =0
		self.__LOG_CITYLOST = 0
		self.__LOG_CITYBUILDING = 0
		self.__LOG_TECH = 0
		self.__LOG_UNITBUILD = 0
		self.__LOG_UNITKILLED = 1
		self.__LOG_UNITLOST = 0
		self.__LOG_UNITPROMOTED = 0
		self.__LOG_UNITSELECTED = 0
		self.__LOG_UNITPILLAGE = 0
		self.__LOG_GOODYRECEIVED = 0
		self.__LOG_GREATPERSON = 0
		self.__LOG_RELIGION = 0
		self.__LOG_RELIGIONSPREAD = 0
		self.__LOG_GOLDENAGE = 0
		self.__LOG_ENDGOLDENAGE = 0
		self.__LOG_WARPEACE = 0
		self.__LOG_PUSH_MISSION = 0
		
		## EVENTLIST
		self.EventHandlerMap = {
			'mouseEvent'			: self.onMouseEvent,
			'kbdEvent' 				: self.onKbdEvent,
			'ModNetMessage'					: self.onModNetMessage,
			'Init'					: self.onInit,
			'Update'				: self.onUpdate,
			'UnInit'				: self.onUnInit,
			'OnSave'				: self.onSaveGame,
			'OnPreSave'				: self.onPreSave,
			'OnLoad'				: self.onLoadGame,
			'GameStart'				: self.onGameStart,
			'GameEnd'				: self.onGameEnd,
			'plotRevealed' 			: self.onPlotRevealed,
			'plotFeatureRemoved' 	: self.onPlotFeatureRemoved,
			'plotPicked'			: self.onPlotPicked,
			'nukeExplosion'			: self.onNukeExplosion,
			'gotoPlotSet'			: self.onGotoPlotSet,
			'BeginGameTurn'			: self.onBeginGameTurn,
			'EndGameTurn'			: self.onEndGameTurn,
			'BeginPlayerTurn'		: self.onBeginPlayerTurn,
			'EndPlayerTurn'			: self.onEndPlayerTurn,
			'endTurnReady'			: self.onEndTurnReady,
			'combatResult' 			: self.onCombatResult,
		  'combatLogCalc'	 		: self.onCombatLogCalc,
		  'combatLogHit'				: self.onCombatLogHit,
			'improvementBuilt' 		: self.onImprovementBuilt,
			'improvementDestroyed' 		: self.onImprovementDestroyed,
			'routeBuilt' 		: self.onRouteBuilt,
			'firstContact' 			: self.onFirstContact,
			'cityBuilt' 			: self.onCityBuilt,
			'cityRazed'				: self.onCityRazed,
			'cityAcquired' 			: self.onCityAcquired,
			'cityAcquiredAndKept' 	: self.onCityAcquiredAndKept,
			'cityLost'				: self.onCityLost,
			'cultureExpansion' 		: self.onCultureExpansion,
			'cityGrowth' 			: self.onCityGrowth,
			'cityDoTurn' 			: self.onCityDoTurn,
			'cityBuildingUnit'	: self.onCityBuildingUnit,
			'cityBuildingBuilding'	: self.onCityBuildingBuilding,
			'cityRename'				: self.onCityRename,
			'cityHurry'				: self.onCityHurry,
			'selectionGroupPushMission'		: self.onSelectionGroupPushMission,
			'unitMove' 				: self.onUnitMove,
			'unitSetXY' 			: self.onUnitSetXY,
			'unitCreated' 			: self.onUnitCreated,
			'unitBuilt' 			: self.onUnitBuilt,
			'unitKilled'			: self.onUnitKilled,
			'unitLost'				: self.onUnitLost,
			'unitPromoted'			: self.onUnitPromoted,
			'unitSelected'			: self.onUnitSelected, 
			'UnitRename'				: self.onUnitRename,
			'unitPillage'				: self.onUnitPillage,
			'unitSpreadReligionAttempt'	: self.onUnitSpreadReligionAttempt,
			'unitGifted'				: self.onUnitGifted,
			'unitBuildImprovement'				: self.onUnitBuildImprovement,
			'goodyReceived'        	: self.onGoodyReceived,
			'greatPersonBorn'      	: self.onGreatPersonBorn,
			'buildingBuilt' 		: self.onBuildingBuilt,
			'projectBuilt' 			: self.onProjectBuilt,
			'techAcquired'			: self.onTechAcquired,
			'techSelected'			: self.onTechSelected,
			'religionFounded'		: self.onReligionFounded,
			'religionSpread'		: self.onReligionSpread, 
			'religionRemove'		: self.onReligionRemove, 
			'corporationFounded'	: self.onCorporationFounded,
			'corporationSpread'		: self.onCorporationSpread, 
			'corporationRemove'		: self.onCorporationRemove, 
			'goldenAge'				: self.onGoldenAge,
			'endGoldenAge'			: self.onEndGoldenAge,
			'chat' 					: self.onChat,
			'victory'				: self.onVictory,
			'vassalState'			: self.onVassalState,
			'changeWar'				: self.onChangeWar,
			'setPlayerAlive'		: self.onSetPlayerAlive,
			'playerChangeStateReligion'		: self.onPlayerChangeStateReligion,
			'playerGoldTrade'		: self.onPlayerGoldTrade,
			'windowActivation'		: self.onWindowActivation,
			'gameUpdate'			: self.onGameUpdate,
			'endUnitTurn'    		: self.onEndUnitTurn,	
															# sample generic event
		}
		################## Events List ###############################
		#
		# Dictionary of Events, indexed by EventID (also used at popup context id)
		#   entries have name, beginFunction, applyFunction [, randomization weight...]
		#
		# Normal events first, random events after
		#	
		################## Events List ###############################
		self.Events={
			CvUtil.EventEditCityName : ('EditCityName', self.__eventEditCityNameApply, self.__eventEditCityNameBegin),
			CvUtil.EventEditCity : ('EditCity', self.__eventEditCityApply, self.__eventEditCityBegin),
			CvUtil.EventPlaceObject : ('PlaceObject', self.__eventPlaceObjectApply, self.__eventPlaceObjectBegin),
			CvUtil.EventAwardTechsAndGold: ('AwardTechsAndGold', self.__eventAwardTechsAndGoldApply, self.__eventAwardTechsAndGoldBegin),
			CvUtil.EventEditUnitName : ('EditUnitName', self.__eventEditUnitNameApply, self.__eventEditUnitNameBegin),
			CvUtil.EventWBAllPlotsPopup : ('WBAllPlotsPopup', self.__eventWBAllPlotsPopupApply, self.__eventWBAllPlotsPopupBegin),
			CvUtil.EventWBLandmarkPopup : ('WBLandmarkPopup', self.__eventWBLandmarkPopupApply, self.__eventWBLandmarkPopupBegin),
			CvUtil.EventWBScriptPopup : ('WBScriptPopup', self.__eventWBScriptPopupApply, self.__eventWBScriptPopupBegin),
			CvUtil.EventWBStartYearPopup : ('WBStartYearPopup', self.__eventWBStartYearPopupApply, self.__eventWBStartYearPopupBegin),
			CvUtil.EventShowWonder: ('ShowWonder', self.__eventShowWonderApply, self.__eventShowWonderBegin),
			CvUtil.EventSetHasTrait : ('setHasTrait', self.__eventSetHasTraitApply, self.__eventSetHasTraitBegin),
		}

		Animosity.loadConfigurationData()
		
#################### EVENT STARTERS ######################
	def handleEvent(self, argsList):
		'EventMgr entry point'
		# extract the last 6 args in the list, the first arg has already been consumed
		self.origArgsList = argsList	# point to original
		tag = argsList[0]				# event type string
		idx = len(argsList)-6
		bDummy = false
		self.bDbg, bDummy, self.bAlt, self.bCtrl, self.bShift, self.bAllowCheats = argsList[idx:]
		ret = 0
		if self.EventHandlerMap.has_key(tag):
			fxn = self.EventHandlerMap[tag]
			ret = fxn(argsList[1:idx])
		return ret
		
#################### EVENT APPLY ######################	
	def beginEvent( self, context, argsList=-1 ):
		'Begin Event'
		entry = self.Events[context]
		return entry[2]( argsList )
	
	def applyEvent( self, argsList ):
		'Apply the effects of an event '
		context, playerID, netUserData, popupReturn = argsList
		
		if context == CvUtil.PopupTypeEffectViewer:
			return CvDebugTools.g_CvDebugTools.applyEffectViewer( playerID, netUserData, popupReturn )
		
		entry = self.Events[context]
				
		if ( context not in CvUtil.SilentEvents ):
			self.reportEvent(entry, context, (playerID, netUserData, popupReturn) )
		return entry[1]( playerID, netUserData, popupReturn )   # the apply function

	def reportEvent(self, entry, context, argsList):
		'Report an Event to Events.log '
		if (gc.getGame().getActivePlayer() != -1):
			message = "DEBUG Event: %s (%s)" %(entry[0], gc.getActivePlayer().getName())
			CyInterface().addImmediateMessage(message,"")
			CvUtil.pyPrint(message)
		return 0
		
#################### ON EVENTS ######################
	def onKbdEvent(self, argsList):
		'keypress handler - return 1 if the event was consumed'

		eventType,key,mx,my,px,py = argsList
		game = gc.getGame()
		
		if (self.bAllowCheats):
			# notify debug tools of input to allow it to override the control
			argsList = (eventType,key,self.bCtrl,self.bShift,self.bAlt,mx,my,px,py,gc.getGame().isNetworkMultiPlayer())
			if ( CvDebugTools.g_CvDebugTools.notifyInput(argsList) ):
				return 0
		
		if ( eventType == self.EventKeyDown ):
			theKey=int(key)
			#begin add AW camera
			if (theKey == int(InputTypes.KB_LEFT)):
				if self.bCtrl:
						CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() - 45.0)
						return 1
				elif self.bShift:
						CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() - 10.0)
						return 1
			
			if (theKey == int(InputTypes.KB_RIGHT)):
					if self.bCtrl:
							CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() + 45.0)
							return 1
					elif self.bShift:
							CyCamera().SetBaseTurn(CyCamera().GetBaseTurn() + 10.0)
							return 1
			#end add AW camera			
			CvCameraControls.g_CameraControls.handleInput( theKey )
						
			if (self.bAllowCheats):
				# Shift - T (Debug - No MP)
				if (theKey == int(InputTypes.KB_T)):
					if ( self.bShift ):
						self.beginEvent(CvUtil.EventAwardTechsAndGold)
						#self.beginEvent(CvUtil.EventCameraControlPopup)
						return 1
							
				elif (theKey == int(InputTypes.KB_W)):
					if ( self.bShift and self.bCtrl):
						self.beginEvent(CvUtil.EventShowWonder)
						return 1
							
				# Shift - ] (Debug - currently mouse-overd unit, health += 10
				elif (theKey == int(InputTypes.KB_LBRACKET) and self.bShift ):
					unit = CyMap().plot(px, py).getUnit(0)
					if ( not unit.isNone() ):
						d = min( unit.maxHitPoints()-1, unit.getDamage() + 10 )
						unit.setDamage( d, PlayerTypes.NO_PLAYER )
					
				# Shift - [ (Debug - currently mouse-overd unit, health -= 10
				elif (theKey == int(InputTypes.KB_RBRACKET) and self.bShift ):
					unit = CyMap().plot(px, py).getUnit(0)
					if ( not unit.isNone() ):
						d = max( 0, unit.getDamage() - 10 )
						unit.setDamage( d, PlayerTypes.NO_PLAYER )
					
				elif (theKey == int(InputTypes.KB_F1)):
					if ( self.bShift ):
						CvScreensInterface.replayScreen.showScreen(False)
						return 1
					# don't return 1 unless you want the input consumed
				
				elif (theKey == int(InputTypes.KB_F2)):
					if ( self.bShift ):
						import CvDebugInfoScreen
						CvScreensInterface.showDebugInfoScreen()
						return 1
				
				elif (theKey == int(InputTypes.KB_F3)):
					if ( self.bShift ):
						CvScreensInterface.showDanQuayleScreen(())
						return 1
						
				elif (theKey == int(InputTypes.KB_F4)):
					if ( self.bShift ):
						CvScreensInterface.showUnVictoryScreen(())
						return 1
											
		return 0

	def onModNetMessage(self, argsList):
		'Called whenever CyMessageControl().sendModNetMessage() is called - this is all for you modders!'
		
		iData1, iData2, iData3, iData4, iData5 = argsList
		
		print("Modder's net message!")
		
		CvUtil.pyPrint( 'onModNetMessage' )

	def onInit(self, argsList):
		'Called when Civ starts up'
		CvUtil.pyPrint( 'OnInit' )
		
	def onUpdate(self, argsList):
		'Called every frame'
		fDeltaTime = argsList[0]
		
		# allow camera to be updated
		CvCameraControls.g_CameraControls.onUpdate( fDeltaTime )
		
	def onWindowActivation(self, argsList):
		'Called when the game window activates or deactivates'
		bActive = argsList[0]
		
	def onUnInit(self, argsList):
		'Called when Civ shuts down'
		CvUtil.pyPrint('OnUnInit')
	
	def onPreSave(self, argsList):
		"called before a game is actually saved"
		CvUtil.pyPrint('OnPreSave')
	
	def onSaveGame(self, argsList):
		"return the string to be saved - Must be a string"
		return ""

	def onLoadGame(self, argsList):
		CvAdvisorUtils.resetNoLiberateCities()
		return 0

	def onGameStart(self, argsList):
		'Called at the start of the game'

		if CyGame().getWBMapScript():
			if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_WB_KINSTRIFE):
				cf.addPopupWB(CyTranslator().getText("TXT_KEY_WB_KINSTRIFE_INTRO",()), 'art/interface/popups/Kinstrife.dds')
			if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_WB_WHWORLD):
				cf.addPopupWB(CyTranslator().getText("TXT_KEY_WB_WHWORLD_INTRO",()), 'art/interface/popups/WHWORLD.dds')
		else:
			introMovie = CvIntroMovieScreen.CvIntroMovieScreen()
			introMovie.interfaceScreen()

		for iPlayer in range(gc.getMAX_PLAYERS()):
			player = gc.getPlayer(iPlayer)
			if (player.isAlive() and player.isHuman()):
				if player.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUSTRIA'):
					cf.showUniqueImprovements(iPlayer)

		if (gc.getGame().getGameTurnYear() == gc.getDefineINT("START_YEAR") and not gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ADVANCED_START)):
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setText(u"showDawnOfMan")
					popupInfo.addPopup(iPlayer)
		else:
			CyInterface().setSoundSelectionReady(true)

		if gc.getGame().isPbem():
			for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if (player.isAlive() and player.isHuman()):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_DETAILS)
					popupInfo.setOption1(true)
					popupInfo.addPopup(iPlayer)

		CvAdvisorUtils.resetNoLiberateCities()
					
	def onGameEnd(self, argsList):
		'Called at the End of the game'
		print("Game is ending")
		return

	def onBeginGameTurn(self, argsList):
		'Called at the beginning of the end of each turn'
		iGameTurn = argsList[0]

#		if CyGame().isOption(gc.getInfoTypeForString('GAMEOPTION_NO_PLOT_COUNTER')) == False:
#			cf.doHellTerrain()
		
#		if iGameTurn > 20:
#			cf.doTurnRatcatchersGuild()

		cf.doCivTerrainTurn()
		
		CvTopCivs.CvTopCivs().turnChecker(iGameTurn)

	def onEndGameTurn(self, argsList):
		'Called at the end of the end of each turn'
		iGameTurn = argsList[0]
		
	def onBeginPlayerTurn(self, argsList):
		'Called at the beginning of a players turn'
		iGameTurn, iPlayer = argsList
		pPlayer = gc.getPlayer(iPlayer)

		if pPlayer.isHuman() == False:
			cf.warScript(iPlayer)

#		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_MILITARY')) == gc.getInfoTypeForString('CIVIC_CRUSADERS'):
#			cf.doCrusade(iPlayer)
		
		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_DWARVES'):   
			cf.doTurnDwarves(iPlayer)
			
		if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_INSANE')):
			if CyGame().getSorenRandNum(1000, "Insane") < 20:
				iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_TRAIT_INSANE')
				triggerData = pPlayer.initTriggeredData(iEvent, true, -1, -1, -1, iPlayer, -1, -1, -1, -1, -1)

		if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_ADAPTIVE')):
			iCycle = 100
			if CyGame().getGameSpeedType() == gc.getInfoTypeForString('GAMESPEED_QUICK'):
				iCycle = 75
			if CyGame().getGameSpeedType() == gc.getInfoTypeForString('GAMESPEED_EPIC'):
				iCycle = 150
			if CyGame().getGameSpeedType() == gc.getInfoTypeForString('GAMESPEED_MARATHON'):
				iCycle = 300
			for i in range(10):
				if (i * iCycle) - 5 == iGameTurn:
					iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_TRAIT_ADAPTIVE')
					triggerData = pPlayer.initTriggeredData(iEvent, true, -1, -1, -1, iPlayer, -1, -1, -1, -1, -1)

		if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_BARBARIAN')):
			eTeam = gc.getTeam(gc.getPlayer(gc.getBARBARIAN_PLAYER()).getTeam())
			iTeam = pPlayer.getTeam()
			if eTeam.isAtWar(iTeam) == False:
				if 2 * CyGame().getPlayerScore(iPlayer) >= 3 * CyGame().getPlayerScore(CyGame().getRankPlayer(1)):
					if iGameTurn >= 20:
						eTeam.declareWar(iTeam, false, WarPlanTypes.WARPLAN_LIMITED)
						if (iPlayer == CyGame().getActivePlayer() and pPlayer.isHuman()):
							cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_BARBARIAN_DECLARE_WAR",()), 'art/interface/popups/Barbarian.dds')

	def onEndPlayerTurn(self, argsList):
		'Called at the end of a players turn'
		iGameTurn, iPlayer = argsList
		
		if (gc.getGame().getElapsedGameTurns() == 1):
			if (gc.getPlayer(iPlayer).isHuman()):
				if (gc.getPlayer(iPlayer).canRevolution(0)):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_CHANGECIVIC)
					popupInfo.addPopup(iPlayer)
		
		CvAdvisorUtils.resetAdvisorNags()
		CvAdvisorUtils.endTurnFeats(iPlayer)

	# animosity - Handles the event where a unit moves in the game.
	def onEndUnitTurn(self, argsList):
		genericArgs = argsList[0][0]
		objUnit = genericArgs[0]
		
		objAnimosity.handleEndUnitTurn(objUnit)

	def onEndTurnReady(self, argsList):
		iGameTurn = argsList[0]

	def onFirstContact(self, argsList):
		'Contact'
		iTeamX,iHasMetTeamY = argsList
		if (not self.__LOG_CONTACT):
			return
		CvUtil.pyPrint('Team %d has met Team %d' %(iTeamX, iHasMetTeamY))
	
	def onCombatResult(self, argsList):
		'Combat Result'
		pWinner,pLoser = argsList
		playerX = PyPlayer(pWinner.getOwner())
		unitX = PyInfo.UnitInfo(pWinner.getUnitType())
		playerY = PyPlayer(pLoser.getOwner())
		unitY = PyInfo.UnitInfo(pLoser.getUnitType())
		if (not self.__LOG_COMBAT):
			return
		if playerX and playerX and unitX and playerY:
			CvUtil.pyPrint('Player %d Civilization %s Unit %s has defeated Player %d Civilization %s Unit %s' 
				%(playerX.getID(), playerX.getCivilizationName(), unitX.getDescription(), 
				playerY.getID(), playerY.getCivilizationName(), unitY.getDescription()))

	def onCombatLogCalc(self, argsList):
		'Combat Result'	
		genericArgs = argsList[0][0]
		cdAttacker = genericArgs[0]
		cdDefender = genericArgs[1]
		iCombatOdds = genericArgs[2]
		CvUtil.combatMessageBuilder(cdAttacker, cdDefender, iCombatOdds)
		
	def onCombatLogHit(self, argsList):
		'Combat Message'
		global gCombatMessages, gCombatLog
		genericArgs = argsList[0][0]
		cdAttacker = genericArgs[0]
		cdDefender = genericArgs[1]
		iIsAttacker = genericArgs[2]
		iDamage = genericArgs[3]
		
		if cdDefender.eOwner == cdDefender.eVisualOwner:
			szDefenderName = gc.getPlayer(cdDefender.eOwner).getNameKey()
		else:
			szDefenderName = localText.getText("TXT_KEY_TRAIT_PLAYER_UNKNOWN", ())
		if cdAttacker.eOwner == cdAttacker.eVisualOwner:
			szAttackerName = gc.getPlayer(cdAttacker.eOwner).getNameKey()
		else:
			szAttackerName = localText.getText("TXT_KEY_TRAIT_PLAYER_UNKNOWN", ())

		if (iIsAttacker == 0):				
			combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_HIT", (szDefenderName, cdDefender.sUnitName, iDamage, cdDefender.iCurrHitPoints, cdDefender.iMaxHitPoints))
			CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
			CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)
			if (cdDefender.iCurrHitPoints <= 0):
				combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_DEFEATED", (szAttackerName, cdAttacker.sUnitName, szDefenderName, cdDefender.sUnitName))
				CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
				CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)
		elif (iIsAttacker == 1):
			combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_HIT", (szAttackerName, cdAttacker.sUnitName, iDamage, cdAttacker.iCurrHitPoints, cdAttacker.iMaxHitPoints))
			CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
			CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)
			if (cdAttacker.iCurrHitPoints <= 0):
				combatMessage = localText.getText("TXT_KEY_COMBAT_MESSAGE_DEFEATED", (szDefenderName, cdDefender.sUnitName, szAttackerName, cdAttacker.sUnitName))
				CyInterface().addCombatMessage(cdAttacker.eOwner,combatMessage)
				CyInterface().addCombatMessage(cdDefender.eOwner,combatMessage)

	def onImprovementBuilt(self, argsList):
		'Improvement Built'
		iImprovement, iX, iY = argsList

#		if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_RING_OF_CARCER'):
#			pPlot = CyMap().plot(iX, iY)
#			pPlot.setMinLevel(15)

		if (not self.__LOG_IMPROVEMENT):
			return
		CvUtil.pyPrint('Improvement %s was built at %d, %d'
			%(PyInfo.ImprovementInfo(iImprovement).getDescription(), iX, iY))

	def onImprovementDestroyed(self, argsList):
		'Improvement Destroyed'
		iImprovement, iOwner, iX, iY = argsList

		if iImprovement == gc.getInfoTypeForString('IMPROVEMENT_CURSED_PIT'):
			pPlot = CyMap().plot(iX, iY)
			if pPlot.getNumUnits() > 0:
				pUnit = pPlot.getUnit(0)
				CyInterface().addMessage(pUnit.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_CURSED_PIT_DESTROYED",()),'AS2D_TECH_DING',1,'Art/Interface/Buttons/Improvements/CURSED_PIT.dds',ColorTypes(7),pPlot.getX(),pPlot.getY(),True,True)
				pPlayer = gc.getPlayer(pUnit.getOwner())
				pPlayer.changeGoldenAgeTurns(CyGame().goldenAgeLength())
				pNewPlot = cf.findClearPlot(-1, pPlot)
				if pNewPlot != -1:
					iRestless = gc.getInfoTypeForString('UNIT_RESTLESS')
					iSkeleton = gc.getInfoTypeForString('UNIT_SKELETON_SWORDSMAN')
					iZombie = gc.getInfoTypeForString('UNIT_ZOMBIE')
					bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
					newUnit = bPlayer.initUnit(iRestless, pNewPlot.getX(), pNewPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
					newUnit2 = bPlayer.initUnit(iSkeleton, pNewPlot.getX(), pNewPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
					newUnit3 = bPlayer.initUnit(iRestless, pNewPlot.getX(), pNewPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
					newUnit4 = bPlayer.initUnit(iZombie, pNewPlot.getX(), pNewPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
					newUnit5 = bPlayer.initUnit(iSkeleton, pNewPlot.getX(), pNewPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
					newUnit6 = bPlayer.initUnit(iRestless, pNewPlot.getX(), pNewPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
					newUnit7 = bPlayer.initUnit(iZombie, pNewPlot.getX(), pNewPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)

		if (not self.__LOG_IMPROVEMENT):
			return
		CvUtil.pyPrint('Improvement %s was Destroyed at %d, %d'
			%(PyInfo.ImprovementInfo(iImprovement).getDescription(), iX, iY))

	def onRouteBuilt(self, argsList):
		'Route Built'
		iRoute, iX, iY = argsList
		if (not self.__LOG_IMPROVEMENT):
			return
		CvUtil.pyPrint('Route %s was built at %d, %d'
			%(gc.getRouteInfo(iRoute).getDescription(), iX, iY))

	def onPlotRevealed(self, argsList):
		'Plot Revealed'
		pPlot = argsList[0]
		iTeam = argsList[1]

	def onPlotFeatureRemoved(self, argsList):
		'Plot Revealed'
		pPlot = argsList[0]
		iFeatureType = argsList[1]
		pCity = argsList[2] # This can be null

	def onPlotPicked(self, argsList):
		'Plot Picked'
		pPlot = argsList[0]
		CvUtil.pyPrint('Plot was picked at %d, %d'
			%(pPlot.getX(), pPlot.getY()))

	def onNukeExplosion(self, argsList):
		'Nuke Explosion'
		pPlot, pNukeUnit = argsList
		CvUtil.pyPrint('Nuke detonated at %d, %d'
			%(pPlot.getX(), pPlot.getY()))

	def onGotoPlotSet(self, argsList):
		'Nuke Explosion'
		pPlot, iPlayer = argsList

	def onBuildingBuilt(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList
		player = pCity.getOwner()
		pPlayer = gc.getPlayer(player)
		pPlot = pCity.plot()
		game = gc.getGame()
		iBuildingClassType = gc.getBuildingInfo(iBuildingType).getBuildingClassType()
		
		if ((not gc.getGame().isNetworkMultiPlayer()) and (pCity.getOwner() == gc.getGame().getActivePlayer()) and isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType())):
			if gc.getBuildingInfo(iBuildingType).getMovie():
				# If this is a wonder...
				popupInfo = CyPopupInfo()
				popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
				popupInfo.setData1(iBuildingType)
				popupInfo.setData2(pCity.getID())
				popupInfo.setData3(0)
				popupInfo.setText(u"showWonderMovie")
				popupInfo.addPopup(pCity.getOwner())

#		if iBuildingType == gc.getInfoTypeForString('BUILDING_MAGE_GUILD'):
#			if CyGame().isCorporationFounded(gc.getInfoTypeForString('CORPORATION_CIRCLE_OF_GAELAN')):
#				if CyGame().getHeadquarters(gc.getInfoTypeForString('CORPORATION_CIRCLE_OF_GAELAN')).getOwner() == pCity.getOwner():
#					pCity.setHasCorporation(gc.getInfoTypeForString('CORPORATION_CIRCLE_OF_GAELAN'), True, True, True)

#		if iBuildingType == gc.getInfoTypeForString('BUILDING_TOWER_OF_NECROMANCY'):
#			iUndead = gc.getInfoTypeForString('PROMOTION_UNDEAD')
#			iStrong = gc.getInfoTypeForString('PROMOTION_STRONG')
#			apUnitList = PyPlayer(player).getUnitList()
#			for pUnit in apUnitList:
#				if pUnit.isHasPromotion(iUndead):
#					pUnit.setHasPromotion(iStrong, True)

		CvAdvisorUtils.buildingBuiltFeats(pCity, iBuildingType)

		#Shrines set Holy City
		if gc.getBuildingInfo(iBuildingType).getBuildingClassType() == (gc.getInfoTypeForString('BUILDINGCLASS_ANCESTORS_SHRINE')):
			iReligion = CvUtil.findInfoTypeNum(gc.getReligionInfo, gc.getNumReligionInfos(), "RELIGION_ANCESTORS")
			gc.getGame( ).setHolyCity(iReligion, pCity, 1)
		if gc.getBuildingInfo(iBuildingType).getBuildingClassType() == (gc.getInfoTypeForString('BUILDINGCLASS_CHAOS_SHRINE')):
			iReligion = CvUtil.findInfoTypeNum(gc.getReligionInfo, gc.getNumReligionInfos(), "RELIGION_CHAOS")
			gc.getGame( ).setHolyCity(iReligion, pCity, 1)	
		if gc.getBuildingInfo(iBuildingType).getBuildingClassType() == (gc.getInfoTypeForString('BUILDINGCLASS_SALVATION_SHRINE')):
			iReligion = CvUtil.findInfoTypeNum(gc.getReligionInfo, gc.getNumReligionInfos(), "RELIGION_SALVATION")
			gc.getGame( ).setHolyCity(iReligion, pCity, 1)
		if  gc.getBuildingInfo(iBuildingType).getBuildingClassType() == (gc.getInfoTypeForString('BUILDINGCLASS_DESTRUCTION_SHRINE')):
			iReligion = CvUtil.findInfoTypeNum(gc.getReligionInfo, gc.getNumReligionInfos(), "RELIGION_DESTRUCTION")
			gc.getGame( ).setHolyCity(iReligion, pCity, 1)
		if gc.getBuildingInfo(iBuildingType).getBuildingClassType() == (gc.getInfoTypeForString('BUILDINGCLASS_SPIRITUALITY_SHRINE')):
			iReligion = CvUtil.findInfoTypeNum(gc.getReligionInfo, gc.getNumReligionInfos(), "RELIGION_SPIRITUALITY")
			gc.getGame( ).setHolyCity(iReligion, pCity, 1)
#		if gc.getBuildingInfo(iBuildingType).getBuildingClassType() == (gc.getInfoTypeForString('BUILDINGCLASS_ELVEN_SHRINE')):
#			iReligion = CvUtil.findInfoTypeNum(gc.getReligionInfo, gc.getNumReligionInfos(), "RELIGION_ELVEN")
#			gc.getGame( ).setHolyCity(iReligion, pCity, 1)
		if gc.getBuildingInfo(iBuildingType).getBuildingClassType() == (gc.getInfoTypeForString('BUILDINGCLASS_OLDONES_SHRINE')):
			iReligion = CvUtil.findInfoTypeNum(gc.getReligionInfo, gc.getNumReligionInfos(), "RELIGION_OLDONES")
			gc.getGame( ).setHolyCity(iReligion, pCity, 1)
		if gc.getBuildingInfo(iBuildingType).getBuildingClassType() == (gc.getInfoTypeForString('BUILDINGCLASS_IMMORTALITY_SHRINE')):
			iReligion = CvUtil.findInfoTypeNum(gc.getReligionInfo, gc.getNumReligionInfos(), "RELIGION_IMMORTALITY")
			gc.getGame( ).setHolyCity(iReligion, pCity, 1)
		
		if (not self.__LOG_BUILDING):
			return
		CvUtil.pyPrint('%s was finished by Player %d Civilization %s' 
			%(PyInfo.BuildingInfo(iBuildingType).getDescription(), pCity.getOwner(), gc.getPlayer(pCity.getOwner()).getCivilizationDescription(0)))
	
	def onProjectBuilt(self, argsList):
		'Project Completed'
		pCity, iProjectType = argsList
		game = gc.getGame()
		if ((not gc.getGame().isNetworkMultiPlayer()) and (pCity.getOwner() == gc.getGame().getActivePlayer())):
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iProjectType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(2)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())

		if iProjectType == gc.getInfoTypeForString('PROJECT_GENESIS'):
			cf.genesis(pCity.getOwner())

#		if iProjectType == gc.getInfoTypeForString('PROJECT_GLORY_EVERLASTING'):
#			for iPlayer in range(gc.getMAX_PLAYERS()):
#				pPlayer = gc.getPlayer(iPlayer)
#				player = PyPlayer(iPlayer)
#				if pPlayer.isAlive():
#					apUnitList = player.getUnitList()
#					for pUnit in apUnitList:
#						if (pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_DEMON')) or pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_UNDEAD'))):
#							pUnit.kill(False,0)
#
#		if iProjectType == gc.getInfoTypeForString('PROJECT_RITES_OF_OGHMA'):
#			i = 7
#			if CyMap().getWorldSize() == gc.getInfoTypeForString('WORLDSIZE_DUEL'):
#				i = i - 3
#			if CyMap().getWorldSize() == gc.getInfoTypeForString('WORLDSIZE_TINY'):
#				i = i - 2
#			if CyMap().getWorldSize() == gc.getInfoTypeForString('WORLDSIZE_SMALL'):
#				i = i - 1
#			if CyMap().getWorldSize() == gc.getInfoTypeForString('WORLDSIZE_LARGE'):
#				i = i + 1
#			if CyMap().getWorldSize() == gc.getInfoTypeForString('WORLDSIZE_HUGE'):
#				i = i + 3
#			cf.addBonus('BONUS_MANA',i,'Art/Interface/Buttons/WorldBuilder/mana_button.dds')

		if iProjectType == gc.getInfoTypeForString('PROJECT_NATURES_REVOLT'):
			bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
			py = PyPlayer(gc.getBARBARIAN_PLAYER())
			iAxeman = gc.getInfoTypeForString('UNITCLASS_AXEMAN')
			iBear = gc.getInfoTypeForString('UNIT_BEAR')
			iHunter = gc.getInfoTypeForString('UNITCLASS_HUNTER')
			iLion = gc.getInfoTypeForString('UNIT_LION')
			iScout = gc.getInfoTypeForString('UNITCLASS_SCOUT')
			iTiger = gc.getInfoTypeForString('UNIT_TIGER')
			iWarrior = gc.getInfoTypeForString('UNITCLASS_WARRIOR')
			iWolf = gc.getInfoTypeForString('UNIT_WOLF')
			iWorker = gc.getInfoTypeForString('UNITCLASS_WORKER')
			for pUnit in py.getUnitList():
				bValid = False
				if pUnit.getUnitClassType() == iWorker:
					iNewUnit = iWolf
					bValid = True
				if pUnit.getUnitClassType() == iScout:
					iNewUnit = iLion
					bValid = True
				if pUnit.getUnitClassType() == iWarrior:
					iNewUnit = iLion
					bValid = True
				if pUnit.getUnitClassType() == iHunter:
					iNewUnit = iTiger
					bValid = True
				if pUnit.getUnitClassType() == iAxeman:
					iNewUnit = iBear
					bValid = True
				if bValid:
					newUnit = bPlayer.initUnit(iNewUnit, pUnit.getX(), pUnit.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
					newUnit = bPlayer.initUnit(iNewUnit, pUnit.getX(), pUnit.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
					newUnit = bPlayer.initUnit(iNewUnit, pUnit.getX(), pUnit.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
					pUnit.kill(True,0)
			for iPlayer in range(gc.getMAX_PLAYERS()):
				pPlayer = gc.getPlayer(iPlayer)
				if pPlayer.isAlive():
					py = PyPlayer(iPlayer)
					for pUnit in py.getUnitList():
						if pUnit.isAnimal():
							pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HEROIC_DEFENSE'), True)
							pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HEROIC_DEFENSE2'), True)
							pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HEROIC_STRENGTH'), True)
							pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HEROIC_STRENGTH2'), True)
							
#		if iProjectType == gc.getInfoTypeForString('PROJECT_BLOOD_OF_THE_PHOENIX'):
#			py = PyPlayer(pCity.getOwner())
#			apUnitList = py.getUnitList()
#			for pUnit in apUnitList:
#				if pUnit.isAlive():
#					pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_IMMORTAL'), True)

		if iProjectType == gc.getInfoTypeForString('PROJECT_WITCHHUNT'):
			pPlayer = gc.getPlayer(pCity.getOwner())
			for i in range(pPlayer.getNumCities()):
				iRnd = CyGame().getSorenRandNum(2, "Bob")
				pCity2 = pPlayer.getCity(i)
				StateBelief = pPlayer.getStateReligion()
				if StateBelief == gc.getInfoTypeForString('RELIGION_SALVATION'):
					iRnd = iRnd - 1
				for iTarget in range(gc.getNumReligionInfos()):
					if (StateBelief != iTarget and pCity2.isHasReligion(iTarget) and pCity2.isHolyCityByType(iTarget) == False):
						pCity2.setHasReligion(iTarget, False, True, True)
						iRnd = iRnd + 1
						for i in range(gc.getNumBuildingInfos()):
							if gc.getBuildingInfo(i).getPrereqReligion() == iTarget:
								pCity2.setNumRealBuilding(i, 0)
				if iRnd > 0:
					pCity2.setOccupationTimer(iRnd)

#		if iProjectType == gc.getInfoTypeForString('PROJECT_BIRTHRIGHT_REGAINED'):
#			pPlayer = gc.getPlayer(pCity.getOwner())
#			pPlayer.setFeatAccomplished(FeatTypes.FEAT_GLOBAL_SPELL, False)
#
	def onSelectionGroupPushMission(self, argsList):
		'selection group mission'
		eOwner = argsList[0]
		eMission = argsList[1]
		iNumUnits = argsList[2]
		listUnitIds = argsList[3]
		
		if (not self.__LOG_PUSH_MISSION):
			return
		if pHeadUnit:
			CvUtil.pyPrint("Selection Group pushed mission %d" %(eMission))
	
	def onUnitMove(self, argsList):
		'unit move'
		pPlot,pUnit,pOldPlot = argsList
		player = PyPlayer(pUnit.getOwner())
		unitInfo = PyInfo.UnitInfo(pUnit.getUnitType())
		pPlayer = gc.getPlayer(pUnit.getOwner())

#		if pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FOREST_ANCIENT'):
#			if (pPlot.isOwned() and pPlot.getNumUnits() == 1 and pUnit.isFlying() == False):
#				iChance = gc.getDefineINT('TREANT_SPAWN_CHANCE')
#				if pPlot.isBeingWorked():
#					pCity = pPlot.getWorkingCity()
#					if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_OF_LEAVES')) > 0:
#						iChance = iChance * 3
#				if CyGame().getSorenRandNum(100, "Treant Spawn Chance") <= iChance:
#					p2Player = gc.getPlayer(pPlot.getOwner())
#					eTeam = gc.getTeam(pPlayer.getTeam())
#					i2Team = p2Player.getTeam()
#					if (eTeam.isAtWar(i2Team) and p2Player.getStateReligion() == gc.getInfoTypeForString('RELIGION_FELLOWSHIP_OF_LEAVES')):
#						for i in range(pPlot.getNumUnits()):
#							p2Unit = pPlot.getUnit(i)
#							p2Plot = cf.findClearPlot(p2Unit, -1)
#							if p2Plot != -1:
#								p2Unit.setXY(p2Plot.getX(),p2Plot.getY(), false, true, true)
#								p2Unit.finishMoves()
#						if pPlot.getNumUnits() == 0:
#							newUnit = p2Player.initUnit(gc.getInfoTypeForString('UNIT_TREANT'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
#							newUnit.setDuration(3)
#							CyInterface().addMessage(pUnit.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_TREANT_ENEMY",()),'AS2D_FEATUREGROWTH',1,'Art/Interface/Buttons/Units/Treant.dds',ColorTypes(7),newUnit.getX(),newUnit.getY(),True,True)
#							CyInterface().addMessage(pPlot.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_TREANT",()),'AS2D_FEATUREGROWTH',1,'Art/Interface/Buttons/Units/Treant.dds',ColorTypes(8),newUnit.getX(),newUnit.getY(),True,True)

#		if pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_MAELSTROM'):
#			if CyGame().getSorenRandNum(100, "Maelstrom") <= 25:
#				CyInterface().addMessage(pUnit.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_MAELSTROM_KILL",()),'AS2D_FEATUREGROWTH',1,'Art/Interface/Buttons/Improvements/Maelstrom.dds',ColorTypes(7),pUnit.getX(),pUnit.getY(),True,True)
#				pUnit.kill(False,0)
#			else:
#				iOcean = gc.getInfoTypeForString('TERRAIN_OCEAN')
#				iBestValue = 0
#				pBestPlot = -1
#				for i in range (CyMap().numPlots()):
#					iValue = 0
#					pTargetPlot = CyMap().plotByIndex(i)
#					if pTargetPlot.getTerrainType() == iOcean:
#						iValue = CyGame().getSorenRandNum(1000, "Maelstrom")
#						if pTargetPlot.isOwned() == false:
#							iValue += 1000
#						if iValue > iBestValue:
#							iBestValue = iValue
#							pBestPlot = pTargetPlot
#				if pBestPlot != -1:
#					pUnit.setXY(pBestPlot.getX(), pBestPlot.getY(), false, true, true)
#					pUnit.setDamage(25, PlayerTypes.NO_PLAYER)
#					CyInterface().addMessage(pUnit.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_MAELSTROM_MOVE",()),'AS2D_FEATUREGROWTH',1,'Art/Interface/Buttons/Improvements/Maelstrom.dds',ColorTypes(7),pUnit.getX(),pUnit.getY(),True,True)

#		if pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_POOL_OF_TEARS'):
#			if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_DISEASED')):
#				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DISEASED'), false)
#				CyInterface().addMessage(pUnit.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_POOL_OF_TEARS_DISEASED",()),'AS2D_FEATUREGROWTH',1,'Art/Interface/Buttons/Improvements/Pool of Tears.dds',ColorTypes(8),pUnit.getX(),pUnit.getY(),True,True)
#			if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_ENERVATED')):
#				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENERVATED'), false)
#				CyInterface().addMessage(pUnit.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_POOL_OF_TEARS_ENERVATED",()),'AS2D_FEATUREGROWTH',1,'Art/Interface/Buttons/Improvements/Pool of Tears.dds',ColorTypes(8),pUnit.getX(),pUnit.getY(),True,True)
#			if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_PLAGUED')):
#				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_PLAGUED'), false)
#				CyInterface().addMessage(pUnit.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_POOL_OF_TEARS_PLAGUED",()),'AS2D_FEATUREGROWTH',1,'Art/Interface/Buttons/Improvements/Pool of Tears.dds',ColorTypes(8),pUnit.getX(),pUnit.getY(),True,True)
#			if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_POISONED')):
#				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_POISONED'), false)
#				CyInterface().addMessage(pUnit.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_POOL_OF_TEARS_POISONED",()),'AS2D_FEATUREGROWTH',1,'Art/Interface/Buttons/Improvements/Pool of Tears.dds',ColorTypes(8),pUnit.getX(),pUnit.getY(),True,True)
#			if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_WITHERED')):
#				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_WITHERED'), false)
#				CyInterface().addMessage(pUnit.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_POOL_OF_TEARS_WITHERED",()),'AS2D_FEATUREGROWTH',1,'Art/Interface/Buttons/Improvements/Pool of Tears.dds',ColorTypes(8),pUnit.getX(),pUnit.getY(),True,True)

		if (not self.__LOG_MOVEMENT):
			return
		if player and unitInfo:
			CvUtil.pyPrint('Player %d Civilization %s unit %s is moving to %d, %d' 
				%(player.getID(), player.getCivilizationName(), unitInfo.getDescription(), 
				pUnit.getX(), pUnit.getY()))

	def onUnitSetXY(self, argsList):
		'units xy coords set manually'
		pPlot,pUnit = argsList
		player = PyPlayer(pUnit.getOwner())
		unitInfo = PyInfo.UnitInfo(pUnit.getUnitType())
		if (not self.__LOG_MOVEMENT):
			return
		
	def onUnitCreated(self, argsList):
		'Unit Completed'
		unit = argsList[0]
		player = PyPlayer(unit.getOwner())
		pPlayer = gc.getPlayer(unit.getOwner())
		iChanneling2 = gc.getInfoTypeForString('PROMOTION_CHANNELING2')
		iChanneling3 = gc.getInfoTypeForString('PROMOTION_CHANNELING3')

#		if unit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_ADEPT'):
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_AIR'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_AIR1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_AIR2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_AIR3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_BODY'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_BODY1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_BODY2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_BODY3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_CHAOS'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CHAOS1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CHAOS2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CHAOS3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_DEATH'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEATH1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEATH2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEATH3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_EARTH'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_EARTH1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_EARTH2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_EARTH3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_ENCHANTMENT'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENCHANTMENT1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENCHANTMENT2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENCHANTMENT3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_ENTROPY'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENTROPY1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENTROPY2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENTROPY3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_FIRE'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_FIRE1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_FIRE2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_FIRE3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_LAW'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_LAW1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_LAW2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_LAW3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_LIFE'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_LIFE1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_LIFE2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_LIFE3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_METAMAGIC'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_METAMAGIC1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_METAMAGIC2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_METAMAGIC3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_MIND'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MIND1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MIND2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MIND3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_NATURE'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_NATURE1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_NATURE2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_NATURE3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_SHADOW'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SHADOW1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SHADOW2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SHADOW3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_SPIRIT'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SPIRIT1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SPIRIT2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SPIRIT3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_SUN'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SUN1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SUN2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SUN3'), True)
#			iNum = pPlayer.getNumAvailableBonuses(gc.getInfoTypeForString('BONUS_MANA_WATER'))
#			if iNum > 1:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_WATER1'), True)
#				if (iNum > 2 and unit.isHasPromotion(iChanneling2)):
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_WATER2'), True)
#					if (iNum > 3 and unit.isHasPromotion(iChanneling3)):
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_WATER3'), True)
#
#		if unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_ELEMENTAL')):
#			if pPlayer.getNumBuilding(gc.getInfoTypeForString('BUILDING_TOWER_OF_THE_ELEMENTS')) > 0:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_STRONG'), True)
#
#		if unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_UNDEAD')):
#			if pPlayer.getNumBuilding(gc.getInfoTypeForString('BUILDING_TOWER_OF_NECROMANCY')) > 0:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_STRONG'), True)

		if (not self.__LOG_UNITBUILD):
			return

	def onUnitBuilt(self, argsList):
		'Unit Completed'
		city = argsList[0]
		unit = argsList[1]
		player = PyPlayer(city.getOwner())
		pPlayer = gc.getPlayer(unit.getOwner())

		iFreeProm = unit.getFreePromotionPick()
		
#		if unit.getUnitType() == gc.getInfoTypeForString('UNIT_BLOODTHIRSTER'):
#			iPop = city.getPopulation() - 4
#			if iPop <= 1:
#				iPop = 1
#			city.setPopulation(iPop)
#			city.setOccupationTimer(4)

#		if city.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_CHANCEL_OF_GUARDIANS')) > 0:
#			if CyGame().getSorenRandNum(100, "Bob") <= 20:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEFENSIVE'), True)

#		if (city.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_CAVE_OF_ANCESTORS')) > 0 and unit.getUnitCombatType() == (gc.getInfoTypeForString('UNITCOMBAT_ADEPT'))):
#			i = 0
#			for iBonus in range(gc.getNumBonusInfos()):
#				if gc.getBonusInfo(iBonus).getBonusClassType() == gc.getInfoTypeForString('BONUSCLASS_MANA'):
#					if city.hasBonus(iBonus):
#						i = i + 1
#			if i >= 1:
#				unit.changeExperience(i, -1, False, False, False)

#		if unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_GOLEM')):
#			if city.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_BLASTING_WORKSHOP')) > 0:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_FIRE2'), True)
#			if city.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_GRIDLINES')) > 0:
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CITY_GARRISON1'), True)

#		if city.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_ASYLUM')) > 0:
#			if unit.isAlive():
#				if isWorldUnitClass(unit.getUnitClassType()) == False:
#					if CyGame().getSorenRandNum(100, "Bob") <= 10:
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CRAZED'), True)
#						unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ENRAGED'), True)

#		if unit.getUnitType() == gc.getInfoTypeForString('UNIT_ACHERON'):
#			city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_THE_DRAGONS_HORDE'), 1)
#			iX = city.getX()
#			iY = city.getY()
#			for iiX in range(iX-1, iX+2, 1):
#				for iiY in range(iY-1, iY+2, 1):
#					pPlot = CyMap().plot(iiX,iiY)
#					if (pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FOREST') or pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_JUNGLE')):
#						pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_FLAMES'), 0)
#			cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_ACHERON_CREATION",()), str(gc.getUnitInfo(unit.getUnitType()).getImage()))

#		if unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_DWARF')):
#			if city.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_BREWERY')) > 0:
#				unit.changeExperience(2, -1, False, False, False)

#		if unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_DEMON')):
#			if city.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_DEMONS_ALTAR')) > 0:
#				unit.changeExperience(2, -1, False, False, False)

#		if city.isHasCorporation(gc.getInfoTypeForString('CORPORATION_AERONS_BOUNTY')):
#			if unit.getUnitClassType() == gc.getInfoTypeForString('UNITCLASS_ASSASSIN'):
#				unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_AERONS_CHOSEN'), True)

#		if city.isHasCorporation(gc.getInfoTypeForString('CORPORATION_CULT_OF_THE_DRAGON')):
#			if unit.getReligion() == -1:
#				if CyGame().getSorenRandNum(100, "Bob") <= 20:
#					unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_CULT_OF_THE_DRAGON'), True)

		if unit.getFreePromotionPick() < iFreeProm:
			unit.changeFreePromotionPick(iFreeProm - unit.getFreePromotionPick())

#		if city.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_WARRENS')) > 0:
#			if isWorldUnitClass(unit.getUnitClassType()) == False:
#				if isNationalUnitClass(unit.getUnitClassType()) == False:
#					if unit.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_SIEGE'):
#						if unit.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_NAVAL'):
#							newUnit = pPlayer.initUnit(unit.getUnitType(), city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)

		CvAdvisorUtils.unitBuiltFeats(city, unit)
		
		if (not self.__LOG_UNITBUILD):
			return
		CvUtil.pyPrint('%s was finished by Player %d Civilization %s' 
			%(PyInfo.UnitInfo(unit.getUnitType()).getDescription(), player.getID(), player.getCivilizationName()))
	
	def onUnitKilled(self, argsList):
		'Unit Killed'
		unit, iAttacker = argsList
		iPlayer = unit.getOwner()
		player = PyPlayer(iPlayer)
		attacker = PyPlayer(iAttacker)
		pPlayer = gc.getPlayer(iPlayer)

#		if unit.isAlive():
#			iX = unit.getX()
#			iY = unit.getY()
#			for iiX in range(iX-1, iX+2, 1):
#				for iiY in range(iY-1, iY+2, 1):
#					pPlot2 = CyMap().plot(iiX,iiY)
#					if pPlot2.isCity():
#						pCity = pPlot2.getPlotCity()
#						if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_SOUL_FORGE')) > 0:
#							pCity.changeProduction(unit.getExperience() + 10)
#							CyInterface().addMessage(pCity.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_SOUL_FORGE",()),'AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/Buildings/Soulforge.dds',ColorTypes(7),pCity.getX(),pCity.getY(),True,True)
#			pPlot2 = CyMap().plot(iX,iY)
#			if pPlot2.isCity():
#				pCity = pPlot2.getPlotCity()
#				if ((pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_MOKKAS_CAULDRON')) > 0) and pCity.getOwner() == unit.getOwner()):
#					iUnit = gc.getInfoTypeForString('UNIT_FLESH_GOLEM')
#					newUnit = pPlayer.initUnit(iUnit, pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
#					newUnit.setBaseCombatStr(unit.baseCombatStr())
#					newUnit.setBaseCombatStrDefense(unit.baseCombatStrDefense())
#					newUnit.setDamage(50, PlayerTypes.NO_PLAYER)
#					CyInterface().addMessage(unit.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_MOKKAS_CAULDRON",()),'AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/Buildings/Mokkas Cauldron.dds',ColorTypes(7),pCity.getX(),pCity.getY(),True,True)
#			if (unit.getReligion() == gc.getInfoTypeForString('RELIGION_COUNCIL_OF_ESUS') or unit.getReligion() == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL') or unit.getReligion() == gc.getInfoTypeForString('RELIGION_OCTOPUS_OVERLORDS') or unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_DEATH1')) or unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_ENTROPY1'))):
#				cf.giftUnit(gc.getInfoTypeForString('UNIT_MANES'), gc.getInfoTypeForString('CIVILIZATION_INFERNAL'), 0, unit.plot(), unit.getOwner())
#				cf.giftUnit(gc.getInfoTypeForString('UNIT_MANES'), gc.getInfoTypeForString('CIVILIZATION_INFERNAL'), 0, unit.plot(), unit.getOwner())
#			if (unit.getReligion() == gc.getInfoTypeForString('RELIGION_THE_EMPYREAN') or unit.getReligion() == gc.getInfoTypeForString('RELIGION_THE_ORDER') or unit.getReligion() == gc.getInfoTypeForString('RELIGION_RUNES_OF_KILMORPH') or pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_MERCURIANS')):
#				cf.giftUnit(gc.getInfoTypeForString('UNIT_ANGEL'), gc.getInfoTypeForString('CIVILIZATION_MERCURIANS'), unit.getExperience(), unit.plot(), unit.getOwner())

#		if unit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SPIRIT_GUIDE')):
#			if unit.getExperience() > 0:
#				iRnd = CyGame().getSorenRandNum(pPlayer.getNumUnits(), "Spirit Guide")
#				pUnit = pPlayer.getUnit(iRnd)
#				iXP = unit.getExperience() / 2
#				pUnit.changeExperience(iXP, -1, false, false, false)
#				unit.changeExperience(iXP * -1, -1, false, false, false)
#				CyInterface().addMessage(unit.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_SPIRIT_GUIDE",()),'AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/Promotions/SpiritGuide.dds',ColorTypes(7),pUnit.getX(),pUnit.getY(),True,True)

#		if unit.getUnitType() == gc.getInfoTypeForString('UNIT_TREANT'):
#			pPlot = unit.plot()
#			if pPlot.getFeatureType() == -1:
#				if pPlot.canHaveFeature(gc.getInfoTypeForString('FEATURE_FOREST_NEW')):
#					pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_FOREST_NEW'), 0)

#		if unit.getUnitType() == gc.getInfoTypeForString('UNIT_BASIUM') or unit.getUnitType() == gc.getInfoTypeForString('UNIT_HYBOREM'):
#			for iTrait in range(gc.getNumTraitInfos()):
#				if pPlayer.hasTrait(iTrait):
#					CyMessageControl().sendApplyEvent(5013, EventContextTypes.EVENTCONTEXT_ALL, (iPlayer,iTrait,False))

		if (not self.__LOG_UNITKILLED):
			return
		CvUtil.pyPrint('Player %d Civilization %s Unit %s was killed by Player %d' 
			%(player.getID(), player.getCivilizationName(), PyInfo.UnitInfo(unit.getUnitType()).getDescription(), attacker.getID()))

	def onUnitLost(self, argsList):
		'Unit Lost'
		unit = argsList[0]
		player = PyPlayer(unit.getOwner())
		if (not self.__LOG_UNITLOST):
			return
		CvUtil.pyPrint('%s was lost by Player %d Civilization %s' 
			%(PyInfo.UnitInfo(unit.getUnitType()).getDescription(), player.getID(), player.getCivilizationName()))
	
	def onUnitPromoted(self, argsList):
		'Unit Promoted'
		pUnit, iPromotion = argsList
		player = PyPlayer(pUnit.getOwner())
		if (not self.__LOG_UNITPROMOTED):
			return
		CvUtil.pyPrint('Unit Promotion Event: %s - %s' %(player.getCivilizationName(), pUnit.getName(),))
	
	def onUnitSelected(self, argsList):
		'Unit Selected'
		unit = argsList[0]
		player = PyPlayer(unit.getOwner())
		if (not self.__LOG_UNITSELECTED):
			return
		CvUtil.pyPrint('%s was selected by Player %d Civilization %s' 
			%(PyInfo.UnitInfo(unit.getUnitType()).getDescription(), player.getID(), player.getCivilizationName()))
	
	def onUnitRename(self, argsList):
		'Unit is renamed'
		pUnit = argsList[0]
		if (pUnit.getOwner() == gc.getGame().getActivePlayer()):
			self.__eventEditUnitNameBegin(pUnit)
	
	def onUnitPillage(self, argsList):
		'Unit pillages a plot'
		pUnit, iImprovement, iRoute, iOwner = argsList
		iPlotX = pUnit.getX()
		iPlotY = pUnit.getY()
		pPlot = CyMap().plot(iPlotX, iPlotY)
		
		if (not self.__LOG_UNITPILLAGE):
			return
		CvUtil.pyPrint("Player %d's %s pillaged improvement %d and route %d at plot at (%d, %d)" 
			%(iOwner, PyInfo.UnitInfo(pUnit.getUnitType()).getDescription(), iImprovement, iRoute, iPlotX, iPlotY))
	
	def onUnitSpreadReligionAttempt(self, argsList):
		'Unit tries to spread religion to a city'
		pUnit, iReligion, bSuccess = argsList
		
		iX = pUnit.getX()
		iY = pUnit.getY()
		pPlot = CyMap().plot(iX, iY)
		pCity = pPlot.getPlotCity()
	
	def onUnitGifted(self, argsList):
		'Unit is gifted from one player to another'
		pUnit, iGiftingPlayer, pPlotLocation = argsList
	
	def onUnitBuildImprovement(self, argsList):
		'Unit begins enacting a Build (building an Improvement or Route)'
		pUnit, iBuild, bFinished = argsList

	def onGoodyReceived(self, argsList):
		'Goody received'
		iPlayer, pPlot, pUnit, iGoodyType = argsList
		if (not self.__LOG_GOODYRECEIVED):
			return
		CvUtil.pyPrint('%s received a goody' %(gc.getPlayer(iPlayer).getCivilizationDescription(0)),)
	
	def onGreatPersonBorn(self, argsList):
		'Unit Promoted'
		pUnit, iPlayer, pCity = argsList
		player = PyPlayer(iPlayer)
		if pUnit.isNone() or pCity.isNone():
			return
		if (not self.__LOG_GREATPERSON):
			return
		CvUtil.pyPrint('A %s was born for %s in %s' %(pUnit.getName(), player.getCivilizationName(), pCity.getName()))
	
	def onTechAcquired(self, argsList):
		'Tech Acquired'
		iTechType, iTeam, iPlayer, bAnnounce = argsList
		# Note that iPlayer may be NULL (-1) and not a refer to a player object
		
		# Show tech splash when applicable
		if (iPlayer > -1 and bAnnounce and not CyInterface().noTechSplash()):
			if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
				if ((not gc.getGame().isNetworkMultiPlayer()) and (iPlayer == gc.getGame().getActivePlayer())):
					popupInfo = CyPopupInfo()
					popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
					popupInfo.setData1(iTechType)
					popupInfo.setText(u"showTechSplash")
					popupInfo.addPopup(iPlayer)

#		if (iPlayer != -1 and iPlayer != gc.getBARBARIAN_PLAYER()):
#			pPlayer = gc.getPlayer(iPlayer)
#			iReligion = -1
#			if iTechType == gc.getInfoTypeForString('TECH_CORRUPTION_OF_SPIRIT'):
#				iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_THE_ASHEN_VEIL')
#				iReligion = gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL')
#			if iTechType == gc.getInfoTypeForString('TECH_ORDERS_FROM_HEAVEN'):
#				iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_THE_ORDER')
#				iReligion = gc.getInfoTypeForString('RELIGION_THE_ORDER')
#			if iTechType == gc.getInfoTypeForString('TECH_WAY_OF_THE_FORESTS'):
#				iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_FELLOWSHIP_OF_LEAVES')
#				iReligion = gc.getInfoTypeForString('RELIGION_FELLOWSHIP_OF_LEAVES')
#			if iTechType == gc.getInfoTypeForString('TECH_WAY_OF_THE_EARTHMOTHER'):
#				iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_RUNES_OF_KILMORPH')
#				iReligion = gc.getInfoTypeForString('RELIGION_RUNES_OF_KILMORPH')
#			if iTechType == gc.getInfoTypeForString('TECH_MESSAGE_FROM_THE_DEEP'):
#				iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_OCTOPUS_OVERLORDS')
#				iReligion = gc.getInfoTypeForString('RELIGION_OCTOPUS_OVERLORDS')
#			if iTechType == gc.getInfoTypeForString('TECH_HONOR'):
#				iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_EMPRYREAN')
#				iReligion = gc.getInfoTypeForString('RELIGION_THE_EMPYREAN')
#			if iTechType == gc.getInfoTypeForString('TECH_DECEPTION'):
#				iUnit = gc.getInfoTypeForString('UNIT_NIGHTWATCH')
#				iReligion = gc.getInfoTypeForString('RELIGION_COUNCIL_OF_ESUS')
#			if iReligion != -1:
#				if CyGame().isReligionFounded(iReligion):
#					cf.giftUnit(iUnit, pPlayer.getCivilizationType(), 0, -1, -1)

#		if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_HYBOREM_OR_BASIUM) == false:
#			if (iTechType == gc.getInfoTypeForString('TECH_INFERNAL_PACT') and iPlayer != -1):
#				iCount = 0
#				for iTeam in range(gc.getMAX_TEAMS()):
#					eTeam = gc.getTeam(iTeam)
#					if eTeam.isHasTech(gc.getInfoTypeForString('TECH_INFERNAL_PACT')):
#						iCount = iCount + 1
#				if iCount == 1:
#					iInfernalPlayer = cf.getOpenPlayer()
#					pBestPlot = -1
#					iBestPlot = -1
#					for i in range (CyMap().numPlots()):
#						pPlot = CyMap().plotByIndex(i)
#						iPlot = -1
#						if pPlot.isWater() == False:
#							if pPlot.getNumUnits() == 0:
#								if pPlot.isCity() == False:
#									if pPlot.isImpassable() == False:
#										iPlot = CyGame().getSorenRandNum(500, "Place Hyborem")
#										iPlot = iPlot + (pPlot.area().getNumTiles() * 2)
#										iPlot = iPlot + (pPlot.area().getNumUnownedTiles() * 10)
#										if pPlot.isOwned() == False:
#											iPlot = iPlot + 500
#										if pPlot.getOwner() == iPlayer:
#											iPlot = iPlot + 200
#						if iPlot > iBestPlot:
#							iBestPlot = iPlot
#							pBestPlot = pPlot
#					if (iInfernalPlayer != -1 and pBestPlot != -1):
#						CyGame().addPlayerAdvanced(iInfernalPlayer, -1, gc.getInfoTypeForString('LEADER_HYBOREM'), gc.getInfoTypeForString('CIVILIZATION_INFERNAL'))
#						iFounderTeam = gc.getPlayer(iPlayer).getTeam()
#						eFounderTeam = gc.getTeam(gc.getPlayer(iPlayer).getTeam())
#						iInfernalTeam = gc.getPlayer(iInfernalPlayer).getTeam()
#						eInfernalTeam = gc.getTeam(iInfernalTeam)
#						for iTech in range(gc.getNumTechInfos()):
#							if eFounderTeam.isHasTech(iTech):
#								eInfernalTeam.setHasTech(iTech, true, iInfernalPlayer, true, false)
#						eFounderTeam.signOpenBorders(iFounderTeam)
#						eInfernalTeam.signOpenBorders(iInfernalTeam)
#						iBarbTeam = gc.getPlayer(gc.getBARBARIAN_PLAYER()).getTeam()
#						eInfernalTeam.makePeace(iBarbTeam)
#						newUnit1 = gc.getPlayer(iInfernalPlayer).initUnit(gc.getInfoTypeForString('UNIT_HYBOREM'), pBestPlot.getX(), pBestPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#						newUnit1.setHasPromotion(gc.getInfoTypeForString('PROMOTION_IMMORTAL'), true)
#						newUnit1.setHasCasted(true)
#						newUnit2 = gc.getPlayer(iInfernalPlayer).initUnit(gc.getInfoTypeForString('UNIT_LONGBOWMAN'), pBestPlot.getX(), pBestPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#						newUnit2.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MOBILITY1'), true)
#						newUnit3 = gc.getPlayer(iInfernalPlayer).initUnit(gc.getInfoTypeForString('UNIT_LONGBOWMAN'), pBestPlot.getX(), pBestPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#						newUnit3.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MOBILITY1'), true)
#						newUnit4 = gc.getPlayer(iInfernalPlayer).initUnit(gc.getInfoTypeForString('UNIT_SECT_OF_FLIES'), pBestPlot.getX(), pBestPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#						newUnit4.setHasPromotion(gc.getInfoTypeForString('PROMOTION_IRON_WEAPONS'), true)
#						newUnit4.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MOBILITY1'), true)
#						newUnit5 = gc.getPlayer(iInfernalPlayer).initUnit(gc.getInfoTypeForString('UNIT_SECT_OF_FLIES'), pBestPlot.getX(), pBestPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#						newUnit5.setHasPromotion(gc.getInfoTypeForString('PROMOTION_IRON_WEAPONS'), true)
#						newUnit5.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MOBILITY1'), true)
#						newUnit6 = gc.getPlayer(iInfernalPlayer).initUnit(gc.getInfoTypeForString('UNIT_WORKER'), pBestPlot.getX(), pBestPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#						newUnit6.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEMON'), true)
#						newUnit7 = gc.getPlayer(iInfernalPlayer).initUnit(gc.getInfoTypeForString('UNIT_IMP'), pBestPlot.getX(), pBestPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#						newUnit7.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MOBILITY1'), true)
#						newUnit8 = gc.getPlayer(iInfernalPlayer).initUnit(gc.getInfoTypeForString('UNIT_MANES'), pBestPlot.getX(), pBestPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#						newUnit9 = gc.getPlayer(iInfernalPlayer).initUnit(gc.getInfoTypeForString('UNIT_MANES'), pBestPlot.getX(), pBestPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#						newUnit10 = gc.getPlayer(iInfernalPlayer).initUnit(gc.getInfoTypeForString('UNIT_MANES'), pBestPlot.getX(), pBestPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#						newUnit11 = gc.getPlayer(iInfernalPlayer).initUnit(gc.getInfoTypeForString('UNIT_SETTLER'), pBestPlot.getX(), pBestPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#						newUnit11.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MOBILITY1'), true)
#						newUnit11.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SENTRY'), true)
#						newUnit11.setHasPromotion(gc.getInfoTypeForString('PROMOTION_SENTRY2'), true)
#						newUnit11.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEMON'), true)
#						if gc.getPlayer(iPlayer).isHuman():
#							popupInfo = CyPopupInfo()
#							popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
#							popupInfo.setText(CyTranslator().getText("TXT_KEY_POPUP_CONTROL_INFERNAL",()))
#							popupInfo.setData1(iPlayer)
#							popupInfo.setData2(iInfernalPlayer)
#							popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_YES", ()), "")
#							popupInfo.addPythonButton(CyTranslator().getText("TXT_KEY_POPUP_NO", ()), "")
#							popupInfo.setOnClickedPythonCallback("reassignPlayer")
#							popupInfo.addPopup(iPlayer)

		if (not self.__LOG_TECH):
			return
		CvUtil.pyPrint('%s was finished by Team %d' 
			%(PyInfo.TechnologyInfo(iTechType).getDescription(), iTeam))
	
	def onTechSelected(self, argsList):
		'Tech Selected'
		iTechType, iPlayer = argsList
		if (not self.__LOG_TECH):
			return
		CvUtil.pyPrint('%s was selected by Player %d' %(PyInfo.TechnologyInfo(iTechType).getDescription(), iPlayer))
	
	def onReligionFounded(self, argsList):
		'Religion Founded'
		iReligion, iFounder = argsList
		player = PyPlayer(iFounder)
		
#		iCityId = gc.getGame().getHolyCity(iReligion).getID()
#		if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
#			if ((not gc.getGame().isNetworkMultiPlayer()) and (iFounder == gc.getGame().getActivePlayer())):
#				popupInfo = CyPopupInfo()
#				popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
#				popupInfo.setData1(iReligion)
#				popupInfo.setData2(iCityId)
#				if (iReligion == gc.getInfoTypeForString('RELIGION_THE_EMPYREAN') or iReligion == gc.getInfoTypeForString('RELIGION_COUNCIL_OF_ESUS')):
#					popupInfo.setData3(3)
#				else:
#					popupInfo.setData3(1)
#				popupInfo.setText(u"showWonderMovie")
#				popupInfo.addPopup(iFounder)
		
		if (not self.__LOG_RELIGION):
			return
		CvUtil.pyPrint('Player %d Civilization %s has founded %s'
			%(iFounder, player.getCivilizationName(), gc.getReligionInfo(iReligion).getDescription()))

	def onReligionSpread(self, argsList):
		'Religion Has Spread to a City'
		iReligion, iOwner, pSpreadCity = argsList
		player = PyPlayer(iOwner)
#		iOrder = gc.getInfoTypeForString('RELIGION_THE_ORDER')
		pPlayer = gc.getPlayer(iOwner)

#		if iReligion == iOrder and CyGame().getGameTurn() != CyGame().getStartTurn():
#			if (pPlayer.getStateReligion() == iOrder and pSpreadCity.getOccupationTimer() <= 0):
#				if (CyGame().getSorenRandNum(100, "Order Spawn") < gc.getDefineINT('ORDER_SPAWN_CHANCE')):
#					eTeam = gc.getTeam(pPlayer.getTeam())
#					if eTeam.isHasTech(gc.getInfoTypeForString('TECH_FANATICISM')):
#						iUnit = gc.getInfoTypeForString('UNIT_CRUSADER')
#						CyInterface().addMessage(iOwner,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_ORDER_SPAWN_CRUSADER",()),'AS2D_UNIT_BUILD_UNIT',1,'Art/Interface/Buttons/Units/Crusader.dds',ColorTypes(8),pSpreadCity.getX(),pSpreadCity.getY(),True,True)
#					else:
#						iUnit = gc.getInfoTypeForString('UNIT_DISCIPLE_THE_ORDER')
#						CyInterface().addMessage(iOwner,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_ORDER_SPAWN_ACOLYTE",()),'AS2D_UNIT_BUILD_UNIT',1,'Art/Interface/Buttons/Units/Disciple Order.dds',ColorTypes(8),pSpreadCity.getX(),pSpreadCity.getY(),True,True)
#					newUnit = pPlayer.initUnit(iUnit, pSpreadCity.getX(), pSpreadCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)

		if (not self.__LOG_RELIGIONSPREAD):
			return
		CvUtil.pyPrint('%s has spread to Player %d Civilization %s city of %s'
			%(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pSpreadCity.getName()))

	def onReligionRemove(self, argsList):
		'Religion Has been removed from a City'
		iReligion, iOwner, pRemoveCity = argsList
		player = PyPlayer(iOwner)
		if (not self.__LOG_RELIGIONSPREAD):
			return
		CvUtil.pyPrint('%s has been removed from Player %d Civilization %s city of %s'
			%(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pRemoveCity.getName()))
				
	def onCorporationFounded(self, argsList):
		'Corporation Founded'
		iCorporation, iFounder = argsList
		player = PyPlayer(iFounder)
		pPlayer = gc.getPlayer(iFounder)

#		iCircle = gc.getInfoTypeForString('CORPORATION_CIRCLE_OF_GAELAN')
#		iMageGuild = gc.getInfoTypeForString('BUILDING_MAGE_GUILD')
#		if iCorporation == iCircle:
#			for i in range(pPlayer.getNumCities()):
#				pCity = pPlayer.getCity(i)
#				if pCity.getNumRealBuilding(iMageGuild) > 0:
#					pCity.setHasCorporation(iCircle, True, True, True)

		if (not self.__LOG_RELIGION):
			return
		CvUtil.pyPrint('Player %d Civilization %s has founded %s'
			%(iFounder, player.getCivilizationName(), gc.getCorporationInfo(iCorporation).getDescription()))

	def onCorporationSpread(self, argsList):
		'Corporation Has Spread to a City'
		iCorporation, iOwner, pSpreadCity = argsList
		player = PyPlayer(iOwner)
		if (not self.__LOG_RELIGIONSPREAD):
			return
		CvUtil.pyPrint('%s has spread to Player %d Civilization %s city of %s'
			%(gc.getCorporationInfo(iCorporation).getDescription(), iOwner, player.getCivilizationName(), pSpreadCity.getName()))

	def onCorporationRemove(self, argsList):
		'Corporation Has been removed from a City'
		iCorporation, iOwner, pRemoveCity = argsList
		player = PyPlayer(iOwner)
		if (not self.__LOG_RELIGIONSPREAD):
			return
		CvUtil.pyPrint('%s has been removed from Player %d Civilization %s city of %s'
			%(gc.getReligionInfo(iReligion).getDescription(), iOwner, player.getCivilizationName(), pRemoveCity.getName()))
				
	def onGoldenAge(self, argsList):
		'Golden Age'
		iPlayer = argsList[0]
		player = PyPlayer(iPlayer)
		if (not self.__LOG_GOLDENAGE):
			return
		CvUtil.pyPrint('Player %d Civilization %s has begun a golden age'
			%(iPlayer, player.getCivilizationName()))

	def onEndGoldenAge(self, argsList):
		'End Golden Age'
		iPlayer = argsList[0]
		player = PyPlayer(iPlayer)
		if (not self.__LOG_ENDGOLDENAGE):
			return
		CvUtil.pyPrint('Player %d Civilization %s golden age has ended'
			%(iPlayer, player.getCivilizationName()))

	def onChangeWar(self, argsList):
		'War Status Changes'
		bIsWar = argsList[0]
		iTeam = argsList[1]
		iRivalTeam = argsList[2]
		if (not self.__LOG_WARPEACE):
			return
		if (bIsWar):
			strStatus = "declared war"
		else:
			strStatus = "declared peace"
		CvUtil.pyPrint('Team %d has %s on Team %d'
			%(iTeam, strStatus, iRivalTeam))
	
	def onChat(self, argsList):
		'Chat Message Event'
		chatMessage = "%s" %(argsList[0],)
		
	def onSetPlayerAlive(self, argsList):
		'Set Player Alive Event'
		iPlayerID = argsList[0]
		bNewValue = argsList[1]
		CvUtil.pyPrint("Player %d's alive status set to: %d" %(iPlayerID, int(bNewValue)))

#		if (bNewValue == False and gc.getGame().getGameTurnYear() >= 5):
#			pPlayer = gc.getPlayer(iPlayerID)
#			if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_GOOD'):
#				CyGame().changeGlobalCounter(5)
#			if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
#				CyGame().changeGlobalCounter(-5)
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_ALEXIS'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_CALABIM",()),'art/interface/popups/Alexis.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_AMELANCHIER'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LJOSALFAR",()),'art/interface/popups/Amelanchier.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_ARENDEL'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LJOSALFAR",()),'art/interface/popups/Arendel.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_ARTURUS'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_KHAZAD",()),'art/interface/popups/Arturus.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_AURIC'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_ILLIANS",()),'art/interface/popups/Auric.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_BASIUM'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_MERCURIANS",()),'art/interface/popups/Basium.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_BEERI'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LUCHUIRP",()),'art/interface/popups/Beeri.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_CAPRIA'):
#				if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_WB_RETURN_OF_WINTER):
#					cf.addPopup(CyTranslator().getText("TXT_KEY_WB_RETURN_OF_WINTER_CAPRIA_DEFEATED",()),'art/interface/popups/Capria.dds')
#					for iPlayer in range(gc.getMAX_PLAYERS()):
#						pPlayer = gc.getPlayer(iPlayer)
#						if pPlayer.isAlive():
#							if pPlayer.isHuman():
#								for iUnit in range(pPlayer.getNumUnits()):
#									pUnit = pPlayer.getUnit(iUnit)
#									pUnit.changeExperience(2, -1, False, False, False)
#				else:
#					cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_BANNOR",()),'art/interface/popups/Capria.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_CARDITH'):
#				if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_WB_RETURN_OF_WINTER):
#					cf.addPopup(CyTranslator().getText("TXT_KEY_WB_RETURN_OF_WINTER_CARDITH_DEFEATED",()),'art/interface/popups/Cardith.dds')
#					for iPlayer in range(gc.getMAX_PLAYERS()):
#						pPlayer = gc.getPlayer(iPlayer)
#						if pPlayer.isAlive():
#							if pPlayer.isHuman():
#								pPlayer.changeGold(250)
#				else:
#					cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_KURIOTATES",()),'art/interface/popups/Cardith.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_CASSIEL'):
#				if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_WB_RETURN_OF_WINTER):
#					cf.addPopup(CyTranslator().getText("TXT_KEY_WB_RETURN_OF_WINTER_CASSIEL_DEFEATED",()),'art/interface/popups/Cassiel.dds')
#					for iPlayer in range(gc.getMAX_PLAYERS()):
#						pPlayer = gc.getPlayer(iPlayer)
#						if pPlayer.isAlive():
#							if pPlayer.isHuman():
#								pCity = pPlayer.getCapitalCity()
#								pPlayer.initUnit(gc.getInfoTypeForString('UNIT_PRIEST_OF_LEAVES'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
#								pPlayer.initUnit(gc.getInfoTypeForString('UNIT_PRIEST_OF_LEAVES'), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
#				else:
#					cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_GRIGORI",()),'art/interface/popups/Cassiel.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_CHARADON'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_DOVIELLO",()),'art/interface/popups/Charadon.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_DAIN'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_AMURITES",()),'art/interface/popups/Dain.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_EINION'):
#				if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_WB_RETURN_OF_WINTER):
#					cf.addPopup(CyTranslator().getText("TXT_KEY_WB_RETURN_OF_WINTER_EINION_DEFEATED",()),'art/interface/popups/Einion.dds')
#					for iPlayer in range(gc.getMAX_PLAYERS()):
#						pPlayer = gc.getPlayer(iPlayer)
#						if pPlayer.isAlive():
#							if pPlayer.isHuman():
#								for iCity in range(pPlayer.getNumCities()):
#									pCity = pPlayer.getCity(iCity)
#									pCity.changeCulture(iPlayer, 300, True)
#				else:
#					cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_ELOHIM",()),'art/interface/popups/Einion.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_ETHNE'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_ELOHIM",()),'art/interface/popups/Ethne.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_FAERYL'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_SVARTALFAR",()),'art/interface/popups/Faeryl.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_FALAMAR'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LANUN",()),'art/interface/popups/Falamar.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_FLAUROS'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_CALABIM",()),'art/interface/popups/Flauros.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_GARRIM'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LUCHUIRP",()),'art/interface/popups/Garrim.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_HANNAH'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_HANNAH",()),'art/interface/popups/Hannah.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_HYBOREM'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_INFERNAL",()),'art/interface/popups/Hyborem.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_JONAS'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_CLAN_OF_EMBERS",()),'art/interface/popups/Jonus.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_KANDROS'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_KHAZAD",()),'art/interface/popups/Kandros.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_KEELYN'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_KEELYN",()),'art/interface/popups/Keelyn.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_MAHALA'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_DOVIELLO",()),'art/interface/popups/Mahala.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_SANDALPHON'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_SIDAR",()),'art/interface/popups/Sandalphon.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_OS-GABELLA'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_SHEAIM",()),'art/interface/popups/Os-Gabella.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_PERPENTACH'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_BALSERAPHS",()),'art/interface/popups/Perpentach.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_RHOANNA'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_HIPPUS",()),'art/interface/popups/Rhoanna.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_SABATHIEL'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_BANNOR",()),'art/interface/popups/Sabathiel.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_SHEELBA'):
#				if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_WB_BARBARIAN_ASSAULT):
#					for iTeam in range(gc.getMAX_TEAMS()):
#						eTeam = gc.getTeam(iTeam)
#						if eTeam.isAlive():
#							if eTeam.isHuman():
#								gc.getGame().setWinner(iTeam, 2)
#				else:
#					cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_CLAN_OF_EMBERS",()),'art/interface/popups/Sheelba.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_TASUNKE'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_HIPPUS",()),'art/interface/popups/Tasunke.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_TEBRYN'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_SHEAIM",()),'art/interface/popups/Tebryn.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_THESSA'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_LJOSALFAR",()),'art/interface/popups/Thessa.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_VALLEDIA'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_AMURITES",()),'art/interface/popups/Valledia.dds')
#			if pPlayer.getLeaderType() == gc.getInfoTypeForString('LEADER_VARN'):
#				cf.addPopup(CyTranslator().getText("TXT_KEY_POPUP_DEFEATED_MALAKIM",()),'art/interface/popups/Varn.dds')

	def onPlayerChangeStateReligion(self, argsList):
		'Player changes his state religion'
		iPlayer, iNewReligion, iOldReligion = argsList
		
	def onPlayerGoldTrade(self, argsList):
		'Player Trades gold to another player'
		iFromPlayer, iToPlayer, iGoldAmount = argsList

	def onCityBuilt(self, argsList):
		'City Built'
		city = argsList[0]
		pPlot = city.plot()
		pPlayer = gc.getPlayer(city.getOwner())

#Greenskins/Ogres force Religion Destruction, thx to Sto! 		
		lDestCivs = ['CIVILIZATION_ORCS','CIVILIZATION_GOBLINS','CIVILIZATION_HOBGOB','CIVILIZATION_OGRELORDS']
		lDestCivsType = [ CvUtil.findInfoTypeNum(gc.getCivilizationInfo, gc.getNumCivilizationInfos, item ) for item in lDestCivs]
		religionDestruction = gc.getInfoTypeForString('RELIGION_DESTRUCTION')

		if pPlayer.getCivilizationType() in lDestCivsType :
				for iReligion in range(gc.getNumReligionInfos()): 
					city.setHasReligion(religionDestruction, True, True, True)
#ElvenReligion
		lElvenCivs = ['CIVILIZATION_LOREN','CIVILIZATION_NAGGAROTH','CIVILIZATION_ULTHUAN']
		lElvenCivsType = [ CvUtil.findInfoTypeNum(gc.getCivilizationInfo, gc.getNumCivilizationInfos, item ) for item in lElvenCivs]
		religionElven = gc.getInfoTypeForString('RELIGION_ELVEN')
		
		if pPlayer.getCivilizationType() in lElvenCivsType :
				for iReligion in range(gc.getNumReligionInfos()): 
					city.setHasReligion(religionElven, True, True, True)
#Oldones Religion
		religionOldOnes = gc.getInfoTypeForString('RELIGION_OLDONES')
		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUSTRIA'):
			city.setHasReligion(religionOldOnes, True, True, True)
		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_AMAZONS'):
			city.setHasReligion(religionOldOnes, True, True, True)				
#Ancestor Religion
		religionAncestors = gc.getInfoTypeForString('RELIGION_ANCESTORS')
		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_DWARVES'):
			city.setHasReligion(religionAncestors, True, True, True)		

#Elves
		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ULTHUAN'):
			city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_HIGHELVEN_CITIZENS'), 1)
		
		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LOREN'):
			city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_WOODELVEN_CITIZENS'), 1)	
			
		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_NAGGAROTH'):
			city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_DARKELVEN_CITIZENS'), 1)
			
#Kinstrife			
		if CyGame().getWBMapScript():
			if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_WB_KINSTRIFE):
				if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_NAGGAROTH'):
					city.setPopulation(3)
					city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_ELDER_COUNCIL'), 1)
					city.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_FORGE'), 1)#more to add here			

#Barbarian
					
		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BARBARIAN'):
			eTeam = gc.getTeam(gc.getPlayer(gc.getBARBARIAN_PLAYER()).getTeam())
			iUnit = gc.getInfoTypeForString('UNIT_WARRIOR')
			if (eTeam.isHasTech(gc.getInfoTypeForString('TECH_BRONZE_WORKING')) or CyGame().getStartEra() > gc.getInfoTypeForString('ERA_ANCIENT') ):
				iUnit = gc.getInfoTypeForString('UNIT_AXEMAN')
			if (eTeam.isHasTech(gc.getInfoTypeForString('TECH_IRON_WORKING')) or CyGame().getStartEra() > gc.getInfoTypeForString('ERA_CLASSICAL') ):
				iUnit = gc.getInfoTypeForString('UNIT_MARAUDER')
			newUnit = pPlayer.initUnit(iUnit, city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
#			newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ORC'), true)
			newUnit2 = pPlayer.initUnit(iUnit, city.getX(), city.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
#			newUnit2.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ORC'), true)

		if (city.getOwner() == gc.getGame().getActivePlayer()):
			self.__eventEditCityNameBegin(city, False)	
		CvUtil.pyPrint('City Built Event: %s' %(city.getName()))
		
	def onCityRazed(self, argsList):
		'City Razed'
		city, iPlayer = argsList
		iOwner = city.findHighestCulture()

		# Partisans!
#		if city.getPopulation > 1 and iOwner != -1 and iPlayer != -1:
#			owner = gc.getPlayer(iOwner)
#			if not owner.isBarbarian() and owner.getNumCities() > 0:
#				if gc.getTeam(owner.getTeam()).isAtWar(gc.getPlayer(iPlayer).getTeam()):
#					if gc.getNumEventTriggerInfos() > 0: # prevents mods that don't have events from getting an error
#						iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_PARTISANS')
#						if iEvent != -1 and gc.getGame().isEventActive(iEvent) and owner.getEventTriggerWeight(iEvent) >= 0:
#							triggerData = owner.initTriggeredData(iEvent, true, -1, city.getX(), city.getY(), iPlayer, city.getID(), -1, -1, -1, -1)

#		pPlayer = gc.getPlayer(iPlayer)
#		if gc.getPlayer(city.getOriginalOwner()).getAlignment() == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
#			for i in range(city.getPopulation()):
#				cf.giftUnit(gc.getInfoTypeForString('UNIT_MANES'), gc.getInfoTypeForString('CIVILIZATION_INFERNAL'), 0, city.plot(), city.getOwner())
#
#		if gc.getPlayer(city.getOriginalOwner()).getAlignment() == gc.getInfoTypeForString('ALIGNMENT_NEUTRAL'):
#			for i in range((city.getPopulation() / 4) + 1):
#				cf.giftUnit(gc.getInfoTypeForString('UNIT_MANES'), gc.getInfoTypeForString('CIVILIZATION_INFERNAL'), 0, city.plot(), city.getOwner())
#				cf.giftUnit(gc.getInfoTypeForString('UNIT_MANES'), gc.getInfoTypeForString('CIVILIZATION_INFERNAL'), 0, city.plot(), city.getOwner())
#				cf.giftUnit(gc.getInfoTypeForString('UNIT_ANGEL'), gc.getInfoTypeForString('CIVILIZATION_MERCURIANS'), 0, city.plot(), city.getOwner())
#
#		if gc.getPlayer(city.getOriginalOwner()).getAlignment() == gc.getInfoTypeForString('ALIGNMENT_GOOD'):
#			for i in range((city.getPopulation() / 2) + 1):
#				cf.giftUnit(gc.getInfoTypeForString('UNIT_ANGEL'), gc.getInfoTypeForString('CIVILIZATION_MERCURIANS'), 0, city.plot(), city.getOwner())
#
#		if city.getPopulation > 1 and iOwner != -1 and iPlayer != -1:
#			if CyGame().getSorenRandNum(100, "Brotherhood of Wardens") <= 25:
#				owner = gc.getPlayer(iOwner)
#				iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_BROTHERHOOD_OF_WARDENS_SPREAD')
#				triggerData = owner.initTriggeredData(iEvent, true, -1, city.getX(), city.getY(), iPlayer, city.getID(), -1, -1, -1, -1)

		CvUtil.pyPrint("City Razed Event: %s" %(city.getName(),))
	
	def onCityAcquired(self, argsList):
		'City Acquired'
		iPreviousOwner,iNewOwner,pCity,bConquest,bTrade = argsList
		CvUtil.pyPrint('City Acquired Event: %s' %(pCity.getName()))
	
	def onCityAcquiredAndKept(self, argsList):
		'City Acquired and Kept'
		iOwner,pCity = argsList

#		if pCity.isHasCorporation(gc.getInfoTypeForString('CORPORATION_BROTHERHOOD_OF_WARDENS')):
#			pCity.setHasCorporation(gc.getInfoTypeForString('CORPORATION_BROTHERHOOD_OF_WARDENS'), False, False, False)

		CvUtil.pyPrint('City Acquired and Kept Event: %s' %(pCity.getName()))
	
	def onCityLost(self, argsList):
		'City Lost'
		city = argsList[0]
		player = PyPlayer(city.getOwner())
		if (not self.__LOG_CITYLOST):
			return
		CvUtil.pyPrint('City %s was lost by Player %d Civilization %s' 
			%(city.getName(), player.getID(), player.getCivilizationName()))
	
	def onCultureExpansion(self, argsList):
		'City Culture Expansion'
		pCity = argsList[0]
		iPlayer = argsList[1]
		CvUtil.pyPrint("City %s's culture has expanded" %(pCity.getName(),))
	
	def onCityGrowth(self, argsList):
		'City Population Growth'
		pCity = argsList[0]
		iPlayer = argsList[1]
		CvUtil.pyPrint("%s has grown" %(pCity.getName(),))
	
	def onCityDoTurn(self, argsList):
		'City Production'
		pCity = argsList[0]
		iPlayer = argsList[1]
		pPlot = pCity.plot()
		pPlayer = gc.getPlayer(pCity.getOwner())

		
		#Greenskins/Ogres force Religion Destruction if city is not under occupation, remove Destruction if civ is not Greenskin/Ogre, thx to Sto!
		lDestCivs = ['CIVILIZATION_ORCS','CIVILIZATION_GOBLINS','CIVILIZATION_HOBGOB','CIVILIZATION_OGRELORDS']
		lDestCivsType = [ CvUtil.findInfoTypeNum(gc.getCivilizationInfo, gc.getNumCivilizationInfos, item ) for item in lDestCivs]
		religionDestruction = gc.getInfoTypeForString('RELIGION_DESTRUCTION')

		if not pCity.isOccupation():
			if pPlayer.getCivilizationType() in lDestCivsType:
					for iReligion in range(gc.getNumReligionInfos()): 
							if ( pCity.isHasReligion(iReligion) and iReligion != religionDestruction ):
								if not pCity.isHolyCityByType(iReligion):#don't execute if city is holy city
									pCity.setHasReligion(iReligion, False, True, True)
									pCity.setPopulation(1)
									CyInterface().addMessage(pCity.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_ORC_MASSACRE",()),'AS2D_REVOLTSTART',1,'Art/Interface/Buttons/Units/goblin chariot.dds',ColorTypes(8),pCity.getX(),pCity.getY(),True,True)
					if not pCity.isHasReligion(religionDestruction):
							pCity.setHasReligion(religionDestruction, True, True, True)
			else :
					if (pCity.isHasReligion(religionDestruction)):
						if not pCity.isHolyCityByType(religionDestruction):#don't execute if city is holy city
							pCity.setHasReligion(religionDestruction, False, True, True)
							pCity.setPopulation(1)
							CyInterface().addMessage(pCity.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_MASSACRE_ON_ORCS",()),'AS2D_REVOLTSTART',1,'Art/Interface/Buttons/Units/goblin chariot.dds',ColorTypes(8),pCity.getX(),pCity.getY(),True,True)

		#Elves assimilation
		if not pCity.isOccupation():
			if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ULTHUAN'):
				if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_HIGHELVEN_CITIZENS')) == 0:
					pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_HIGHELVEN_CITIZENS'), 1)

		if not pCity.isOccupation():
			if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LOREN'):
				if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_WOODELVEN_CITIZENS')) == 0:
					pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_WOODELVEN_CITIZENS'), 1)	
			
		if not pCity.isOccupation():
			if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_NAGGAROTH'):
				if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_DARKELVEN_CITIZENS')) == 0:
					pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_DARKELVEN_CITIZENS'), 1)
					
#		if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_CITADEL_OF_LIGHT')) > 0:
#			iX = pCity.getX()
#			iY = pCity.getY()
#			eTeam = gc.getTeam(pPlayer.getTeam())
#			iBestValue = 0
#			pBestPlot = -1
#			for iiX in range(iX-2, iX+3, 1):
#				for iiY in range(iY-2, iY+3, 1):
#					pPlot2 = CyMap().plot(iiX,iiY)
#					bEnemy = false
#					bNeutral = false
#					iValue = 0
#					if pPlot2.isVisibleEnemyUnit(iPlayer):
#						for i in range(pPlot2.getNumUnits()):
#							pUnit = pPlot2.getUnit(i)
#							if eTeam.isAtWar(pUnit.getTeam()):
#								iValue += 5 * pUnit.baseCombatStr()
#							else:
#								bNeutral = true
#						if (iValue > iBestValue and bNeutral == false):
#							iBestValue = iValue
#							pBestPlot = pPlot2
#			if (pBestPlot != -1 and pPlot.getNumUnits() != 0):
#				caster = -1
#				for i in range(pPlot.getNumUnits()):
#					pUnit = pPlot.getUnit(i)
#					if (caster == -1 or pUnit.getLevel() > caster.getLevel()):
#						caster = pUnit
#				for i in range(pBestPlot.getNumUnits()):
#					pUnit = pBestPlot.getUnit(i)
#					pUnit.doDamage(10, 30, caster, gc.getInfoTypeForString('DAMAGE_FIRE'), true)
#				if (pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FOREST') or pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_JUNGLE')):
#					if CyGame().getSorenRandNum(100, "Flames Spread") <= gc.getDefineINT('FLAMES_SPREAD_CHANCE'):
#						pPlot.setImprovementType(gc.getInfoTypeForString('IMPROVEMENT_SMOKE'))
#				CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_PILLAR_OF_FIRE'),pBestPlot.getPoint())

#		if pCity.isHasCorporation(gc.getInfoTypeForString('CORPORATION_BROTHERHOOD_OF_WARDENS')):
#			if CyGame().getSorenRandNum(100, "Brotherhood of Wardens") <= 50:
#				bAlert = False
#				iX = pCity.getX()
#				iY = pCity.getY()
#				eTeam = pPlayer.getTeam()
#				for iiX in range(iX-2, iX+3, 1):
#					for iiY in range(iY-2, iY+3, 1):
#						pPlot2 = CyMap().plot(iiX,iiY)
#						if pPlot2.isVisibleEnemyUnit(iPlayer):
#							bAlert = True
#				if bAlert == True:
#					infoCiv = gc.getCivilizationInfo(pPlayer.getCivilizationType())
#					iBestUnit = -1
#					iBestValue = -1
#					for iUnitClass in range(gc.getNumUnitClassInfos()):
#						iUnit = infoCiv.getCivilizationUnits(iUnitClass)
#						if iUnit != -1:
#							if pCity.canTrain(iUnit, False, False):
#								if gc.getUnitClassInfo(iUnitClass).getMaxGlobalInstances() == -1:
#									iValue = gc.getUnitInfo(iUnit).getCombatDefense()
#									if iValue > iBestValue:
#										iBestValue = iValue
#										iBestUnit = iUnit
#					if iBestUnit != -1:
#						newUnit = pPlayer.initUnit(iBestUnit, pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
#						newUnit.setDuration(4)
#						CyInterface().addMessage(iPlayer,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_BROTHERHOOD_OF_WARDENS_SPAWN",()),'AS2D_BROTHERHOOD_OF_WARDENS',1,'Art/Interface/Buttons/Corporations/Brotherhood of Wardens.dds',ColorTypes(8),pCity.getX(),pCity.getY(),True,True)

#		if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_HALL_OF_MIRRORS')) > 0:
#			if CyGame().getSorenRandNum(100, "Hall of Mirrors") <= 100:
#				pUnit = -1
#				iX = pCity.getX()
#				iY = pCity.getY()
#				eTeam = gc.getTeam(pPlayer.getTeam())
#				for iiX in range(iX-1, iX+2, 1):
#					for iiY in range(iY-1, iY+2, 1):
#						pPlot2 = CyMap().plot(iiX,iiY)
#						if pPlot2.isVisibleEnemyUnit(iPlayer):
#							for i in range(pPlot2.getNumUnits()):
#								pUnit2 = pPlot2.getUnit(i)
#								if eTeam.isAtWar(pUnit2.getTeam()):
#									pUnit = pUnit2
#				if pUnit != -1:
#					newUnit = pPlayer.initUnit(pUnit.getUnitType(), pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#					newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ILLUSION'), true)
#					newUnit.setDuration(3)

#		if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_EYES_AND_EARS_NETWORK')) > 0:
#			iArete = gc.getInfoTypeForString('TECH_ARETE')
#			iHiddenPaths = gc.getInfoTypeForString('TECH_HIDDEN_PATHS')
#			iInfernalPact = gc.getInfoTypeForString('TECH_INFERNAL_PACT')
#			iMindStapling = gc.getInfoTypeForString('TECH_MIND_STAPLING')
#			iSeafaring = gc.getInfoTypeForString('TECH_SEAFARING')
#			eTeam = gc.getTeam(pPlayer.getTeam())
#			listTeams = []
#			for iPlayer2 in range(gc.getMAX_PLAYERS()):
#				pPlayer2 = gc.getPlayer(iPlayer2)
#				if (pPlayer2.isAlive() and iPlayer2 != iPlayer):
#					iTeam2 = pPlayer2.getTeam()
#					if eTeam.isOpenBorders(iTeam2):
#						listTeams.append(gc.getTeam(iTeam2))
#			if len(listTeams) >= 3:
#				for iTech in range(gc.getNumTechInfos()):
#					if (iTech != iArete and iTech != iMindStapling and iTech != iHiddenPaths and iTech != iInfernalPact and iTech != iSeafaring):
#						if eTeam.isHasTech(iTech) == False:
#							iCount = 0
#							for i in range(len(listTeams)):
#								if listTeams[i].isHasTech(iTech):
#									iCount = iCount + 1
#							if iCount >= 3:
#								eTeam.setHasTech(iTech, True, iPlayer, False, True)
#								CyInterface().addMessage(iPlayer,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_EYES_AND_EARS_NETWORK_FREE_TECH",()),'AS2D_TECH_DING',1,'Art/Interface/Buttons/Buildings/Eyesandearsnetwork.dds',ColorTypes(8),pCity.getX(),pCity.getY(),True,True)

#		pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_GYPSY_CAMP'), 0)
#		for i in range(pPlot.getNumUnits()):
#			pUnit = pPlot.getUnit(i)
#			if (pUnit.getUnitType() == gc.getInfoTypeForString('UNIT_GYPSY_WAGON') or pUnit.getUnitType() == gc.getInfoTypeForString('UNIT_LOKI')):
#				if pUnit.getOwner() != pCity.getOwner():
#					pCity.setNumRealBuilding(gc.getInfoTypeForString('BUILDING_GYPSY_CAMP'), 1)
#					gc.getPlayer(pUnit.getOwner()).changeGold(1)
#					if (pUnit.getUnitType() == gc.getInfoTypeForString('UNIT_LOKI') and CyGame().getSorenRandNum(100, "Loki") <= gc.getDefineINT('LOKI_UNREST_CHANCE')):
#						pCity.changeHurryAngerTimer(2)
#						CyInterface().addMessage(pUnit.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_LOKI_UNREST_ENEMY",()),'AS2D_REVOLTSTART',1,'Art/Interface/Buttons/Units/Loki.dds',ColorTypes(8),pCity.getX(),pCity.getY(),True,True)
#						CyInterface().addMessage(pCity.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_LOKI_UNREST",()),'AS2D_REVOLTSTART',1,'Art/Interface/Buttons/Units/Loki.dds',ColorTypes(8),pCity.getX(),pCity.getY(),True,True)
#						if pCity.getCulture(pCity.getOwner()) < 1:
#							gc.getPlayer(pUnit.getOwner()).acquireCity(pCity,false,false)

#		if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_PLANAR_GATE')) > 0:
#			iMax = 1
#			iMult = 1
#			if CyGame().getGlobalCounter() >= 50:
#				iMax = 2
#				iMult = 1.5
#			if CyGame().getGlobalCounter() >= 75:
#				iMax = 3
#				iMult = 2
#			if CyGame().getGlobalCounter() == 100:
#				iMax = 4
#				iMult = 2.5
#			if CyGame().getSorenRandNum(10000, "Planar Gate") <= gc.getDefineINT('PLANAR_GATE_CHANCE') * iMult:
#				listUnits = []
#				iMax = iMax * pPlayer.countNumBuildings(gc.getInfoTypeForString('BUILDING_PLANAR_GATE'))
#				if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_GAMBLING_HOUSE')) > 0:
#					if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_REVELERS')) < iMax:
#						listUnits.append(gc.getInfoTypeForString('UNIT_REVELERS'))
#				if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_MAGE_GUILD')) > 0:
#					if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_MOBIUS_WITCH')) < iMax:
#						listUnits.append(gc.getInfoTypeForString('UNIT_MOBIUS_WITCH'))
#				if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_CARNIVAL')) > 0:
#					if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_CHAOS_MARAUDER')) < iMax:
#						listUnits.append(gc.getInfoTypeForString('UNIT_CHAOS_MARAUDER'))
#				if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_HIPPODROME')) > 0:
#					if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_MANTICORE')) < iMax:
#						listUnits.append(gc.getInfoTypeForString('UNIT_MANTICORE'))
#				if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_PUBLIC_BATHS')) > 0:
#					if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_SUCCUBUS')) < iMax:
#						listUnits.append(gc.getInfoTypeForString('UNIT_SUCCUBUS'))
#				if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_WEAPONSMITH')) > 0:
#					if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_MINOTAUR')) < iMax:
#						listUnits.append(gc.getInfoTypeForString('UNIT_MINOTAUR'))
#				if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_VEIL')) > 0:
#					if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_TAR_DEMON')) < iMax:
#						listUnits.append(gc.getInfoTypeForString('UNIT_TAR_DEMON'))
#				if len(listUnits) > 0:
#					iUnit = listUnits[CyGame().getSorenRandNum(len(listUnits), "Planar Gate")]
#					newUnit = pPlayer.initUnit(iUnit, pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#					CyInterface().addMessage(iPlayer,True,25,CyTranslator().getText("TXT_KEY_MESSAGE_PLANAR_GATE",()),'AS2D_DISCOVERBONUS',1,gc.getUnitInfo(newUnit.getUnitType()).getButton(),ColorTypes(8),pCity.getX(),pCity.getY(),True,True)
#					if iUnit == gc.getInfoTypeForString('UNIT_MOBIUS_WITCH'):
#						promotions = [ 'PROMOTION_AIR1','PROMOTION_BODY1','PROMOTION_CHAOS1','PROMOTION_DEATH1','PROMOTION_EARTH1','PROMOTION_ENCHANTMENT1','PROMOTION_ENTROPY1','PROMOTION_FIRE1','PROMOTION_LAW1','PROMOTION_LIFE1','PROMOTION_MIND1','PROMOTION_NATURE1','PROMOTION_SHADOW1','PROMOTION_SPIRIT1','PROMOTION_SUN1','PROMOTION_WATER1' ]
#						newUnit.setLevel(4)
#						newUnit.setExperience(14, -1)
#						for i in promotions:
#							if CyGame().getSorenRandNum(10, "Bob") == 1:
#								newUnit.setHasPromotion(gc.getInfoTypeForString(i), True)

#		if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_RIDE_OF_THE_NINE_KINGS')) > 0:
#			for i in range(pPlot.getNumUnits()):
#				pUnit = pPlot.getUnit(i)
#				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MORALE'), True)

		if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_SISTERS_OF_SHALLYA')) > 0: 
			pPlayer.setFeatAccomplished(FeatTypes.FEAT_HEAL_UNIT_PER_TURN, true)

		CvAdvisorUtils.cityAdvise(pCity, iPlayer)
	
	def onCityBuildingUnit(self, argsList):
		'City begins building a unit'
		pCity = argsList[0]
		iUnitType = argsList[1]
		if (not self.__LOG_CITYBUILDING):
			return
		CvUtil.pyPrint("%s has begun building a %s" %(pCity.getName(),gc.getUnitInfo(iUnitType).getDescription()))
	
	def onCityBuildingBuilding(self, argsList):
		'City begins building a Building'
		pCity = argsList[0]
		iBuildingType = argsList[1]
		if (not self.__LOG_CITYBUILDING):
			return
		CvUtil.pyPrint("%s has begun building a %s" %(pCity.getName(),gc.getBuildingInfo(iBuildingType).getDescription()))
	
	def onCityRename(self, argsList):
		'City is renamed'
		pCity = argsList[0]
		if (pCity.getOwner() == gc.getGame().getActivePlayer()):
			self.__eventEditCityNameBegin(pCity, True)	
	
	def onCityHurry(self, argsList):
		'City is renamed'
		pCity = argsList[0]
		iHurryType = argsList[1]

	def onVictory(self, argsList):
		'Victory'
		iTeam, iVictory = argsList
		if (iVictory >= 0 and iVictory < gc.getNumVictoryInfos()):

#			if CyGame().getWBMapScript():
#				if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_WB_BARBARIAN_ASSAULT):
#					cf.addPopupWB(CyTranslator().getText("TXT_KEY_WB_BARBARIAN_ASSAULT_VICTORY",()), 'art/interface/popups/Barbarian Assault.dds')
#				if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_WB_RETURN_OF_WINTER):
#					cf.addPopupWB(CyTranslator().getText("TXT_KEY_WB_RETURN_OF_WINTER_VICTORY",()), 'art/interface/popups/Return of Winter.dds')

			victoryInfo = gc.getVictoryInfo(int(iVictory))
			CvUtil.pyPrint("Victory!  Team %d achieves a %s victory"
				%(iTeam, victoryInfo.getDescription()))
	
	def onVassalState(self, argsList):
		'Vassal State'
		iMaster, iVassal, bVassal = argsList
		
		if (bVassal):
			CvUtil.pyPrint("Team %d becomes a Vassal State of Team %d"
				%(iVassal, iMaster))
		else:
			CvUtil.pyPrint("Team %d revolts and is no longer a Vassal State of Team %d"
				%(iVassal, iMaster))
	
	def onGameUpdate(self, argsList):
		'sample generic event, called on each game turn slice'
		genericArgs = argsList[0][0]	# tuple of tuple of my args
		turnSlice = genericArgs[0]
	
	def onMouseEvent(self, argsList):
		'mouse handler - returns 1 if the event was consumed'
		eventType,mx,my,px,py,interfaceConsumed,screens = argsList
		if ( px!=-1 and py!=-1 ):
			if ( eventType == self.EventLButtonDown ):
				if (self.bAllowCheats and self.bCtrl and self.bAlt and CyMap().plot(px,py).isCity() and not interfaceConsumed):
					# Launch Edit City Event
					self.beginEvent( CvUtil.EventEditCity, (px,py) )
					return 1
				
				elif (self.bAllowCheats and self.bCtrl and self.bShift and not interfaceConsumed):
					# Launch Place Object Event
					self.beginEvent( CvUtil.EventPlaceObject, (px, py) )
					return 1
			
		if ( eventType == self.EventBack ):
			return CvScreensInterface.handleBack(screens)
		elif ( eventType == self.EventForward ):
			return CvScreensInterface.handleForward(screens)
		
		return 0
		

#################### TRIGGERED EVENTS ##################	
				
	def __eventEditCityNameBegin(self, city, bRename):
		popup = PyPopup.PyPopup(CvUtil.EventEditCityName, EventContextTypes.EVENTCONTEXT_ALL)
		popup.setUserData((city.getID(), bRename))
		popup.setHeaderString(localText.getText("TXT_KEY_NAME_CITY", ()))
		popup.setBodyString(localText.getText("TXT_KEY_SETTLE_NEW_CITY_NAME", ()))
		popup.createEditBox(city.getName())
		popup.setEditBoxMaxCharCount( 15 )
		popup.launch()
	
	def __eventEditCityNameApply(self, playerID, userData, popupReturn):	
		'Edit City Name Event'
		iCityID = userData[0]
		bRename = userData[1]
		player = gc.getPlayer(playerID)
		city = player.getCity(iCityID)
		cityName = popupReturn.getEditBoxString(0)
		if (len(cityName) > 30):
			cityName = cityName[:30]
		city.setName(cityName, not bRename)

	def __eventEditCityBegin(self, argsList):
		'Edit City Event'
		px,py = argsList
		CvWBPopups.CvWBPopups().initEditCity(argsList)
	
	def __eventEditCityApply(self, playerID, userData, popupReturn):
		'Edit City Event Apply'
		if (getChtLvl() > 0):
			CvWBPopups.CvWBPopups().applyEditCity( (popupReturn, userData) )

	def __eventPlaceObjectBegin(self, argsList):
		'Place Object Event'
		CvDebugTools.CvDebugTools().initUnitPicker(argsList)
	
	def __eventPlaceObjectApply(self, playerID, userData, popupReturn):
		'Place Object Event Apply'
		if (getChtLvl() > 0):
			CvDebugTools.CvDebugTools().applyUnitPicker( (popupReturn, userData) )

	def __eventAwardTechsAndGoldBegin(self, argsList):
		'Award Techs & Gold Event'
		CvDebugTools.CvDebugTools().cheatTechs()
	
	def __eventAwardTechsAndGoldApply(self, playerID, netUserData, popupReturn):
		'Award Techs & Gold Event Apply'
		if (getChtLvl() > 0):
			CvDebugTools.CvDebugTools().applyTechCheat( (popupReturn) )
	
	def __eventShowWonderBegin(self, argsList):
		'Show Wonder Event'
		CvDebugTools.CvDebugTools().wonderMovie()
	
	def __eventShowWonderApply(self, playerID, netUserData, popupReturn):
		'Wonder Movie Apply'
		if (getChtLvl() > 0):
			CvDebugTools.CvDebugTools().applyWonderMovie( (popupReturn) )
	
	def __eventEditUnitNameBegin(self, argsList):
		pUnit = argsList
		popup = PyPopup.PyPopup(CvUtil.EventEditUnitName, EventContextTypes.EVENTCONTEXT_ALL)
		popup.setUserData((pUnit.getID(),))
		popup.setBodyString(localText.getText("TXT_KEY_RENAME_UNIT", ()))
		popup.createEditBox(pUnit.getNameNoDesc())
		popup.launch()

	def __eventEditUnitNameApply(self, playerID, userData, popupReturn):	
		'Edit Unit Name Event'
		iUnitID = userData[0]
		unit = gc.getPlayer(playerID).getUnit(iUnitID)
		newName = popupReturn.getEditBoxString(0)
		if (len(newName) > 25):
			newName = newName[:25]			
		unit.setName(newName)

	def __eventWBAllPlotsPopupBegin(self, argsList):
		CvScreensInterface.getWorldBuilderScreen().allPlotsCB()
		return
	def __eventWBAllPlotsPopupApply(self, playerID, userData, popupReturn):
		if (popupReturn.getButtonClicked() >= 0):
			CvScreensInterface.getWorldBuilderScreen().handleAllPlotsCB(popupReturn)
		return

	def __eventWBLandmarkPopupBegin(self, argsList):
		CvScreensInterface.getWorldBuilderScreen().setLandmarkCB("")
		#popup = PyPopup.PyPopup(CvUtil.EventWBLandmarkPopup, EventContextTypes.EVENTCONTEXT_ALL)
		#popup.createEditBox(localText.getText("TXT_KEY_WB_LANDMARK_START", ()))
		#popup.launch()
		return

	def __eventWBLandmarkPopupApply(self, playerID, userData, popupReturn):
		if (popupReturn.getEditBoxString(0)):
			szLandmark = popupReturn.getEditBoxString(0)
			if (len(szLandmark)):
				CvScreensInterface.getWorldBuilderScreen().setLandmarkCB(szLandmark)
		return

	def __eventWBScriptPopupBegin(self, argsList):
		popup = PyPopup.PyPopup(CvUtil.EventWBScriptPopup, EventContextTypes.EVENTCONTEXT_ALL)
		popup.setHeaderString(localText.getText("TXT_KEY_WB_SCRIPT", ()))
		popup.createEditBox(CvScreensInterface.getWorldBuilderScreen().getCurrentScript())
		popup.launch()
		return

	def __eventWBScriptPopupApply(self, playerID, userData, popupReturn):
		if (popupReturn.getEditBoxString(0)):
			szScriptName = popupReturn.getEditBoxString(0)
			CvScreensInterface.getWorldBuilderScreen().setScriptCB(szScriptName)
		return

	def __eventWBStartYearPopupBegin(self, argsList):
		popup = PyPopup.PyPopup(CvUtil.EventWBStartYearPopup, EventContextTypes.EVENTCONTEXT_ALL)
		popup.createSpinBox(0, "", gc.getGame().getStartYear(), 1, 5000, -5000)
		popup.launch()
		return

	def __eventWBStartYearPopupApply(self, playerID, userData, popupReturn):
		iStartYear = popupReturn.getSpinnerWidgetValue(int(0))
		CvScreensInterface.getWorldBuilderScreen().setStartYearCB(iStartYear)
		return

	def __eventSetHasTraitBegin(self, argslist):
		return 0
	
	def __eventSetHasTraitApply(self, playerID, userData, popupReturn):
		iPlayer, iTrait, bHas = userData
		pPlayer = gc.getPlayer(iPlayer)
		pPlayer.setHasTrait(iTrait, bHas)
		return 0
